擅长:python、mysql、java
<p>可以将所有URL写入起始URL,但这不是最佳做法。你知道吗</p>
<p>使用</p>
<pre><code>class MySpider(Spider):
name = 'csv'
def start_requests(self):
with open('file.csv') as f:
for line in f:
if not line.strip():
continue
yield Request(line)
</code></pre>
<p>如图所示:
<a href="https://stackoverflow.com/questions/51914391/how-to-loop-through-multiple-urls-to-scrape-from-a-csv-file-in-scrapy">How to loop through multiple URLs to scrape from a CSV file in Scrapy?</a>
相反。你知道吗</p>