美文网首页
豆瓣Top250

豆瓣Top250

作者: 北有魚名為咸 | 来源:发表于2016-12-11 15:23 被阅读0次
#coding=UTF-8
import urllib2
from bs4 import BeautifulSoup
# https://book.douban.com/top250?start=
time=0
sum=25
while time<=225:

    times=str(time)
    url="https://book.douban.com/top250?start="+times

    req = urllib2.urlopen(url)
    content = req.read()
    soup=BeautifulSoup(content,"html.parser")
    print "----------page=" + str(sum/25) + "-----------"
    for link in soup.find_all('div',{"class":"pl2"}):
        for text in link.find_all("a"):
            for none in text.stripped_strings:
                print none

        sum=sum+1
    time=time+25
print sum-25



相关文章

网友评论

      本文标题:豆瓣Top250

      本文链接:https://www.haomeiwen.com/subject/yprpmttx.html