Pass Scrapy Spider a list of URLs to crawl via .txt file

前端 未结 4 668
无人及你
无人及你 2020-12-24 11:16

I\'m a little new to Python and very new to Scrapy.

I\'ve set up a spider to crawl and extract all the information I need. However, I need to pass a .txt file of U

4条回答
  •  我在风中等你
    2020-12-24 11:57

    you could simply read-in the .txt file:

    with open('your_file.txt') as f:
        start_urls = f.readlines()
    

    if you end up with trailing newline characters, try:

    with open('your_file.txt') as f:
        start_urls = [url.strip() for url in f.readlines()]
    

    Hope this helps

提交回复
热议问题