1. 程式人生 > >簡易版爬蟲(豆瓣)

簡易版爬蟲(豆瓣)

douban spa http sta imp bsp ont color run


import requests
import re
def get_douban():

res_str = requests.get("https://movie.douban.com/top250?start=0&filter=")

return res_str.text
def run():

resong = get_douban()

obj = re.compile(‘<span class="title">(?P<name>.*?)</span>.*?<span>(?P<evaluate>.*?)</span>.*?‘
‘<p class="">\\n\s+(?P<director>.*?)&nbsp;&nbsp;&nbsp;?‘, re.S)

ret = obj.finditer(resong)

return ret
def zuz():

for i in run():

yield{"name":i.group(‘name‘),
"evaluate":i.group(‘evaluate‘),
"director":i.group(‘director‘)

}
for i in zuz():

print(i)

簡易版爬蟲(豆瓣)