如何加快Pywikibot? [英] How to speed up Pywikibot?

查看:84
本文介绍了如何加快Pywikibot?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 Pywikibot 构建了一些报告工具.随着事情的发展,现在最多需要2个小时才能完成报告,因此我希望加快速度.主要思想:

I've built some report tools using Pywikibot. As things are growing it now takes up to 2 hours to finish the reports so I'm looking to speed things up. Main ideas:

  • 禁用限制,脚本是只读的,因此page.get(throttle=False)可以处理
  • 缓存
  • 直接数据库访问
  • Disable throttling, the script is read-only, so page.get(throttle=False) handles this
  • Cache
  • Direct database access

不幸的是,我找不到太多有关缓存和数据库访问的文档.似乎只有一种方法可以深入研究代码,而且user-config.py中有关数据库访问的信息有限.如果有的话,我在哪里可以找到有关pywikibot缓存和直接数据库访问的良好文档?

Unfortunately I can't find much documentation about caching and db access. Only way seems to dive into the code, and well, there's limited information about database access in user-config.py. If there is any, where can I find good documentation about pywikibot caching and direct db access?

而且,还有其他方法可以加快速度吗?

And, are there other ways to speed things up?

推荐答案

使用PreloadingGenerator,以便分批加载页面.如果使用直接数据库访问,则为MySQLPageGenerator.

Use PreloadingGenerator so that pages are loaded in batches. Or MySQLPageGenerator if you use direct DB access.

此处中查看示例.

这篇关于如何加快Pywikibot?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆