parent
8833141ae7
commit
5bf20daf2b
@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
import re
|
||||||
|
import requests
|
||||||
|
message=[]
|
||||||
|
for i in range(0,226,25):
|
||||||
|
|
||||||
|
url=f"https://movie.douban.com/top250?start={i}"
|
||||||
|
header={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"}
|
||||||
|
respond=requests.get(url,headers=header)
|
||||||
|
txt=respond.text
|
||||||
|
|
||||||
|
name=re.findall('<span class="title">([^&]+?)</span>',txt)
|
||||||
|
score=re.findall('<span class="rating_num" property="v:average">(.+?)</span>',txt)
|
||||||
|
comment=re.findall('<span class="inq">(.+?)</span>',txt)
|
||||||
|
total=list(zip(name,score,comment))
|
||||||
|
print(total)
|
||||||
|
message.extend(total)
|
||||||
|
for index,i in enumerate(message,start=1):
|
||||||
|
f=open("./phb.txt","w",encoding="utf-8")
|
||||||
|
f.write(f"No.{index}:{i[0]}")
|
||||||
|
f.write(f"豆瓣评分:{i[1]}")
|
||||||
|
f.write(f"代表评价:{i[2]}")
|
||||||
|
f.write("-----------------------------------")
|
||||||
|
f.close()
|
||||||
|
with open("./phb.txt","r",encoding="utf-8") as f:
|
||||||
|
print(f.readline())
|
Loading…
Reference in new issue