开始采集

1、获取维基百科的页面

#研究凯文到埃里克的链条主题长度
from urllib.request import urlopen
from bs4 import BeautifulSoup

html = urlopen("http://en.wikipedia.org/wiki/Kevin_Bacon")
bs = BeautifulSoup(html)
for link in bs.findAll("a"):#字符a是标签
    if "href" in link.attrs:#href是属性
        print(link.attrs["href"])#打印属性里的内容

 

posted on 2018-02-02 14:23  告辞  阅读(92)  评论(0)    收藏  举报

导航