Python urllib2爬虫豆瓣小说名称和评分
#-*- coding:utf-8 -*- import urllib2 import re url = 'https://book.douban.com/tag/%E5%B0%8F%E8%AF%B4' request = urllib2.Request(url) urlopen = urllib2.urlopen(request) content = urlopen.read() reg_0 = re.findall(r'title.+"\s*on', content) reg_1 = re.findall(r'rating_nums">.*<', content) for title,score in zip(reg_0,reg_1): title = re.split(r'"',title) score = re.split(r'>|<',score) print title[1],score[1] #<span class="rating_nums">8.6</span>