簡易版爬蟲(豆瓣)
阿新 • • 發佈:2017-07-04
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>.*?) ?‘, 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)
簡易版爬蟲(豆瓣)