

Python爬虫编程思想(153):使用Scrapy抓取数据,抓取多个Url
source link: https://blog.csdn.net/nokiaguy/article/details/125506849
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Python爬虫编程思想(153):使用Scrapy抓取数据,抓取多个Url
在前面的案例中都是只抓取了一个Url对应的页面,但在实际应用中,通常需要抓取多个Url,在爬虫类的start_urls变量中添加多个Url,运行爬虫时就会抓取start_urls变量中所有的Url。下面的代码在start_urls变量中添加了2个Url,运行MultiUrlSpider爬虫后,就会抓取这两个Url对应的页面。
下面的例子通过一个文本文件(urls.txt)提供多个Url,并在爬虫类中读取urls.txt文件中的内容,然后将读取的多个Url存入start_urls变量中。最后会抓取urls.txt文件中所有的Url对应的页面,并输出页面的博文数(本例提供的Url是geekori.com的博文列表页面,如果读者使用其他的Url,需要修改分析页面的逻辑代码)。
Recommend
-
10
Python爬虫编程思想(145):使用Scrapy Shell抓取Web资源
-
24
Python爬虫编程思想(146):创建和使用Scrapy工程 ...
-
2
Python爬虫编程思想(147):在PyCharm中使用Scrapy ...
-
7
Python爬虫编程思想(149):使用Scrapy抓取数据,并通过XPath指定解析规则 ...
-
8
Python爬虫编程思想(150):使用Scrapy抓取数据,并将抓取到的数据保存为多种格式的文件 ...
-
7
Python爬虫编程思想(151):使用Scrapy抓取数据,用ItemLoader保存单条抓取的数据 ...
-
9
Python爬虫编程思想(152):使用Scrapy抓取数据,使用ItemLoader保存多条抓取的数据 ...
-
3
Python爬虫编程思想(155):使用Scrapy处理带隐藏文本框的登录页面
-
2
Python爬虫编程思想(157):使用Scrapy从CSV格式转换到JSON格式 ...
-
6
Python爬虫编程思想(156):使用Scrapy抓取天气预报数据
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK