小编Met*_*ods的帖子

网络抓取工具 - 以下链接

请多多包涵.我是Python的新手 - 但有很多乐趣.我正在尝试编写一个网络爬虫代码,用于搜索丹麦最后一次公投的选举结果.我设法从主页面中提取所有相关链接.现在我希望Python遵循92个链接中的每一个,并从每个页面中收集9条信息.但我很困惑.希望你能给我一个提示.

这是我的代码:

import requests
import urllib2 
from bs4 import BeautifulSoup

# This is the original url http://www.kmdvalg.dk/

soup = BeautifulSoup(urllib2.urlopen('http://www.kmdvalg.dk/').read())

my_list = []
all_links = soup.find_all("a")

for link in all_links:
    link2 = link["href"]
    my_list.append(link2)

for i in my_list[1:93]:
    print i

# The output shows all the links that I would like to follow and gather information from. How do I do that?
Run Code Online (Sandbox Code Playgroud)

python beautifulsoup web-crawler

5
推荐指数
2
解决办法
949
查看次数

标签 统计

beautifulsoup ×1

python ×1

web-crawler ×1