Skip to content

Instantly share code, notes, and snippets.

@masala-man
Last active December 13, 2020 04:05
Show Gist options
  • Save masala-man/7435a7921ff313ae3103da7d444de438 to your computer and use it in GitHub Desktop.
Save masala-man/7435a7921ff313ae3103da7d444de438 to your computer and use it in GitHub Desktop.
[Run Scrapy Spider] Minimal script to run a single scrapy spider.
import scrapy
from scrapy.crawler import CrawlerProcess
class MySpider(scrapy.Spider):
# Your spider definition
...
process = CrawlerProcess({
'USER_AGENT': 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)'
})
process.crawl(MySpider)
process.start() # the script will block here until the crawling is finished
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment