上传文件至 /
This commit is contained in:
23
260402_2509165027.py
Normal file
23
260402_2509165027.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import requests
|
||||
import re
|
||||
import csv
|
||||
import json
|
||||
|
||||
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'
|
||||
}
|
||||
|
||||
url='https://www.douban.com/doulist/3936288/'
|
||||
print('开始爬取豆瓣电影Top250...')
|
||||
response = requests.get(url,headers=header)
|
||||
print(f'状态码: {response.status_code}')
|
||||
print(f'内容长度: {len(response.text)} 字符')
|
||||
html = response.text
|
||||
title_pattern = r'<span class="title">([^<]+)</span>'
|
||||
titles = re.findall(title_pattern, html)
|
||||
print('电影名:',titles)
|
||||
|
||||
|
||||
score_pattern=r'<span class="rating_nums">([^<]+)</span>'
|
||||
scores=re.findall(score_pattern,html)
|
||||
print('评分:',scores)
|
||||
Reference in New Issue
Block a user