我要用基本的关键字和django工具来设置表。现在,我想使用外部googlescraper脚本(https://github.com/NikolaiT/GoogleScraper)来分析这些关键字,一旦它们被添加到django的ORM中(google每个关键字并保存前10个结果供以后分析)。在
在django之外运行此脚本很容易:
import sys
from GoogleScraper import scrape_with_config, GoogleSearchError
from GoogleScraper.database import ScraperSearch, SERP, Link
# very basic usage
def basic_usage():
# See in the config.cfg file for possible values
config = {
'SCRAPING': {
...
if __name__ == '__main__':
usage = 'Usage: {} [basic|image]'.format(sys.argv[0])
if len(sys.argv) != 2:
print(usage)
else:
arg = sys.argv[1]
if arg == 'basic':
...
https://docs.djangoproject.com/en/dev/howto/custom-management-commands/
这是最好的办法吗?在
是否有一些类似的脚本在Django中实现的例子,我可以看到并学习到:)?在
干杯
只需将脚本放在你的应用程序目录中,然后你就可以在视图中导入了
相关问题 更多 >
编程相关推荐