如何使用单个爬网程序从多个域中抓取数据。我已经使用美丽的汤对单个网站进行了爬网,但无法弄清楚如何创建一个通用的网站。如何使用单个爬网程序对多个域进行爬网?
-1
A
回答
0
那么这个问题是有缺陷的,你想刮的网站必须有一些共同点。
from bs4 import BeautifulSoup
from urllib import request
import urllib.request
for counter in range(0,10):
# site = input("Type the name of your website") Python 3+
site = raw_input("Type the name of your website")
# Takes the website you typed and stores it in > site < variable
make_request_to_site = request.urlopen(site).read()
# Makes a request to the site that we stored in a var
soup = BeautifulSoup(make_request_to_site, "html.parser")
# We pass it through BeautifulSoup parser in this case html.parser
# Next we make a loop to find all links in the site that we stored
for link in soup.findAll('a'):
print link['href']
0
如前所述,每个站点有选择(,,等)自己独特的设置。一个单一的通用爬行程序将无法进入一个网址,并直观地理解要抓取的内容。
BeautifulSoup可能不是这种类型的请求的最佳选择。 Scrapy是另一个网络爬虫库,它比BS4更强壮一些。
这里计算器类似的问题:Scrapy approach to scraping multiple URLs
Scrapy文档: https://doc.scrapy.org/en/latest/intro/tutorial.html
相关问题
- 1. Niocchi履带 - 如何添加网址爬行过程中爬行(爬行整个网站)
- 2. 使用其他网址登录后对网页进行爬网
- 3. python网站爬虫(多个网站)
- 4. 使用Python登录后进行爬网
- 5. 使用Storm Crawler进行爬网
- 6. 使用python beautifulsoup进行网页爬虫
- 7. 网络爬虫在哪里获取他们的网站列表进行爬网?
- 8. Java 8 CompletedFuture网络爬虫不爬行一个URL
- 9. 爬行与子域的.net网站
- 10. php爬虫(抓取单个网站)
- 11. 如何使用cms系统如drupal等进行爬网?
- 12. 针对windows的增量爬网支持的网络爬虫
- 13. 运行一个网站爬虫
- 14. 使用多线程来改进网络爬虫/蜘蛛
- 15. Web Scrapy!如何使用Click事件数据进行爬网?
- 16. 如何使用Perl LWP通过欢迎页面进行爬网?
- 17. 网络爬虫
- 18. 将多个模式添加到Schemaclusionrule模式爬网程序
- 19. 如何使Scrapy只下载几个网址即使有多个爬行
- 20. Python简单的网络爬虫错误(无限循环爬行)
- 21. 网络爬虫是否仅依靠主页上的链接来进行爬网?
- 22. 简单的网络爬虫
- 23. 单页网页爬虫PHP
- 24. 使用Scrapy进行多次爬行
- 25. 使网络爬虫在本地下载多个网页
- 26. 抓取单个域及其所有子网站的Java爬虫
- 27. 使用NCrawler运行增量爬网
- 28. 使用蟒蛇和硒爬行网站
- 29. 在应用程序中使用scrapy爬行网站
- 30. 蜘蛛不爬行网页