如何将Scrapy脚本打包到独立的应用程序中? [英] How do I package a Scrapy script into a standalone application?
本文介绍了如何将Scrapy脚本打包到独立的应用程序中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一套Scrapy蜘蛛。它们需要每天从桌面应用程序运行。
(从用户的角度来看)最简单的方法是在另一台Windows计算机上安装并运行它?
I have a set of Scrapy spiders. They need to be run daily from a desktop application. What is the simplest way (from user's point of view) to install and run it on another windows machine?
推荐答案
创建一个脚本(例如 run_spider.py )作为系统命令运行 scrapy crawl< spider_name>
。
Create a script (e.g. run_spider.py) which runs scrapy crawl <spider_name>
as a system command.
run_spider.py
from os import system
output_file_name = 'results.csv'
system('scrapy crawl myspider -o ' + output_file_name + ' -t csv')
然后将该脚本提供给PyInstaller:
Then feed that script to PyInstaller:
pyinstaller run_spider.py
这篇关于如何将Scrapy脚本打包到独立的应用程序中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文