上传文件至 /
This commit is contained in:
1
COMMIT_EDITMSG
Normal file
1
COMMIT_EDITMSG
Normal file
@@ -0,0 +1 @@
|
|||||||
|
完成作业六
|
||||||
13
config
Normal file
13
config
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
[core]
|
||||||
|
repositoryformatversion = 0
|
||||||
|
filemode = false
|
||||||
|
bare = false
|
||||||
|
logallrefupdates = true
|
||||||
|
symlinks = false
|
||||||
|
ignorecase = true
|
||||||
|
[remote "origin"]
|
||||||
|
url = https://gitea.detr.top/2509165046/task-2-3-File-Operations.git
|
||||||
|
fetch = +refs/heads/*:refs/remotes/origin/*
|
||||||
|
[branch "main"]
|
||||||
|
remote = origin
|
||||||
|
merge = refs/heads/main
|
||||||
1
description
Normal file
1
description
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Unnamed repository; edit this file 'description' to name the repository.
|
||||||
44
爬电影.py
44
爬电影.py
@@ -1,23 +1,23 @@
|
|||||||
|
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
|
||||||
}
|
}
|
||||||
|
|
||||||
url = 'https://movie.douban.com/top250'
|
url = 'https://movie.douban.com/top250'
|
||||||
|
|
||||||
print('开始爬取豆瓣电影Top250...')
|
print('开始爬取豆瓣电影Top250...')
|
||||||
response = requests.get(url, headers=headers)
|
response = requests.get(url, headers=headers)
|
||||||
print(f'状态码: {response.status_code}')
|
print(f'状态码: {response.status_code}')
|
||||||
print(f'内容长度: {len(response.text)} 字符')
|
print(f'内容长度: {len(response.text)} 字符')
|
||||||
|
|
||||||
html = response.text
|
html = response.text
|
||||||
|
|
||||||
title_pattern = r'<span class="title">([^<]+)</span>'
|
title_pattern = r'<span class="title">([^<]+)</span>'
|
||||||
titles = re.findall(title_pattern, html)
|
titles = re.findall(title_pattern, html)
|
||||||
|
|
||||||
chinese_titles = [t for t in titles if not t.startswith('/')]
|
chinese_titles = [t for t in titles if not t.startswith('/')]
|
||||||
|
|
||||||
print('电影名称(前10部):')
|
print('电影名称(前10部):')
|
||||||
for i, title in enumerate(chinese_titles[:10], 1):
|
for i, title in enumerate(chinese_titles[:10], 1):
|
||||||
print(f'{i}. {title}')
|
print(f'{i}. {title}')
|
||||||
Reference in New Issue
Block a user