forked from 2509165022/simulated-examination
1
This commit is contained in:
30
q2_1_crawler/1.py
Normal file
30
q2_1_crawler/1.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import re
|
||||
import requests
|
||||
from bs4 import BeautifulSoup as bs
|
||||
import json
|
||||
header = {'User-Agent':'Mozilla/5.0'}
|
||||
url = 'https://exam.detr.top/exam-b/movies'
|
||||
|
||||
html = requests.get(url, headers=header).text
|
||||
# print(html)
|
||||
open('movies.html','w',encoding='utf-8').write(html)
|
||||
# print(html)
|
||||
# print('==============')
|
||||
# fd = bs(html, 'html.parser').find('p', class_='meta')
|
||||
fd = re.search(r'exam_fingerprint:\s*(\S+)',html).group(1)
|
||||
# print(fd)
|
||||
|
||||
resp = bs(html, 'html.parser').find_all('tr', class_='item-row')
|
||||
|
||||
# print(resp)
|
||||
movies = []
|
||||
|
||||
for i in resp:
|
||||
c = []
|
||||
for r in i.find_all('td'):
|
||||
c.append(r.text.strip())
|
||||
movies.append({
|
||||
'id':int(c[0]), 'title':c[1], 'director':c[2], 'year':int(c[3]), 'rating':float(c[4]), 'duration':int(c[5]), 'genre':c[6], 'actors_count':int(c[7])
|
||||
})
|
||||
|
||||
json.dump({'ID':fd, 'movies':movies}, open('movies.json', 'w', encoding='utf-8'), ensure_ascii=False, indent=2)
|
||||
152
q2_1_crawler/movies.html
Normal file
152
q2_1_crawler/movies.html
Normal file
@@ -0,0 +1,152 @@
|
||||
<!-- exam_fingerprint: B-20260625-3464 -->
|
||||
<!-- server_time: 2026-06-25 15:42:14 -->
|
||||
<!-- exam_paper: B -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>电影列表</title>
|
||||
<style>
|
||||
body { font-family: "Microsoft YaHei", sans-serif; margin: 20px; background: #f5f5f5; }
|
||||
h1 { color: #c0392b; }
|
||||
.meta { color: #999; font-size: 12px; margin-bottom: 15px; }
|
||||
.meta code { background: #e9ecef; padding: 2px 6px; border-radius: 3px; }
|
||||
table { width: 100%; border-collapse: collapse; background: white; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
|
||||
th, td { padding: 10px; text-align: left; border-bottom: 1px solid #ddd; }
|
||||
th { background: #c0392b; color: white; }
|
||||
tr:hover { background: #fef5f4; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>电影列表</h1>
|
||||
<p class="meta">数据编号:<code>B-20260625-3464</code></p>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>编号</th>
|
||||
<th>电影名</th>
|
||||
<th>导演</th>
|
||||
<th>上映年份</th>
|
||||
<th>评分</th>
|
||||
<th>时长(分钟)</th>
|
||||
<th>类型</th>
|
||||
<th>主演数</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr class="item-row">
|
||||
<td class="item-id">1</td>
|
||||
<td class="item-title">霸王别姬</td>
|
||||
<td class="item-director">Frank Darabont</td>
|
||||
<td class="item-year">2004</td>
|
||||
<td class="item-rating">6.8</td>
|
||||
<td class="item-duration">179</td>
|
||||
<td class="item-genre">科幻</td>
|
||||
<td class="item-actors-count">3</td>
|
||||
</tr>
|
||||
|
||||
<tr class="item-row">
|
||||
<td class="item-id">2</td>
|
||||
<td class="item-title">放牛班的春天</td>
|
||||
<td class="item-director">陈凯歌</td>
|
||||
<td class="item-year">2019</td>
|
||||
<td class="item-rating">6.7</td>
|
||||
<td class="item-duration">117</td>
|
||||
<td class="item-genre">喜剧</td>
|
||||
<td class="item-actors-count">5</td>
|
||||
</tr>
|
||||
|
||||
<tr class="item-row">
|
||||
<td class="item-id">3</td>
|
||||
<td class="item-title">泰坦尼克号</td>
|
||||
<td class="item-director">Robert Zemeckis</td>
|
||||
<td class="item-year">2015</td>
|
||||
<td class="item-rating">9.1</td>
|
||||
<td class="item-duration">177</td>
|
||||
<td class="item-genre">爱情</td>
|
||||
<td class="item-actors-count">4</td>
|
||||
</tr>
|
||||
|
||||
<tr class="item-row">
|
||||
<td class="item-id">4</td>
|
||||
<td class="item-title">三傻大闹宝莱坞</td>
|
||||
<td class="item-director">James Cameron</td>
|
||||
<td class="item-year">2024</td>
|
||||
<td class="item-rating">7.6</td>
|
||||
<td class="item-duration">117</td>
|
||||
<td class="item-genre">冒险</td>
|
||||
<td class="item-actors-count">5</td>
|
||||
</tr>
|
||||
|
||||
<tr class="item-row">
|
||||
<td class="item-id">5</td>
|
||||
<td class="item-title">阿甘正传</td>
|
||||
<td class="item-director">宫崎骏</td>
|
||||
<td class="item-year">2016</td>
|
||||
<td class="item-rating">8.0</td>
|
||||
<td class="item-duration">146</td>
|
||||
<td class="item-genre">喜剧</td>
|
||||
<td class="item-actors-count">3</td>
|
||||
</tr>
|
||||
|
||||
<tr class="item-row">
|
||||
<td class="item-id">6</td>
|
||||
<td class="item-title">星际穿越</td>
|
||||
<td class="item-director">Christopher Nolan</td>
|
||||
<td class="item-year">2010</td>
|
||||
<td class="item-rating">9.2</td>
|
||||
<td class="item-duration">168</td>
|
||||
<td class="item-genre">爱情</td>
|
||||
<td class="item-actors-count">2</td>
|
||||
</tr>
|
||||
|
||||
<tr class="item-row">
|
||||
<td class="item-id">7</td>
|
||||
<td class="item-title">忠犬八公的故事</td>
|
||||
<td class="item-director">Lasse Hallström</td>
|
||||
<td class="item-year">2016</td>
|
||||
<td class="item-rating">9.3</td>
|
||||
<td class="item-duration">106</td>
|
||||
<td class="item-genre">悬疑</td>
|
||||
<td class="item-actors-count">5</td>
|
||||
</tr>
|
||||
|
||||
<tr class="item-row">
|
||||
<td class="item-id">8</td>
|
||||
<td class="item-title">肖申克的救赎</td>
|
||||
<td class="item-director">Rajkumar Hirani</td>
|
||||
<td class="item-year">2018</td>
|
||||
<td class="item-rating">7.3</td>
|
||||
<td class="item-duration">107</td>
|
||||
<td class="item-genre">剧情</td>
|
||||
<td class="item-actors-count">4</td>
|
||||
</tr>
|
||||
|
||||
<tr class="item-row">
|
||||
<td class="item-id">9</td>
|
||||
<td class="item-title">千与千寻</td>
|
||||
<td class="item-director">Christophe Barratier</td>
|
||||
<td class="item-year">2019</td>
|
||||
<td class="item-rating">7.3</td>
|
||||
<td class="item-duration">118</td>
|
||||
<td class="item-genre">动画</td>
|
||||
<td class="item-actors-count">4</td>
|
||||
</tr>
|
||||
|
||||
<tr class="item-row">
|
||||
<td class="item-id">10</td>
|
||||
<td class="item-title">盗梦空间</td>
|
||||
<td class="item-director">Christopher Nolan</td>
|
||||
<td class="item-year">2008</td>
|
||||
<td class="item-rating">9.3</td>
|
||||
<td class="item-duration">111</td>
|
||||
<td class="item-genre">动画</td>
|
||||
<td class="item-actors-count">5</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
105
q2_1_crawler/movies.json
Normal file
105
q2_1_crawler/movies.json
Normal file
@@ -0,0 +1,105 @@
|
||||
{
|
||||
"ID": "B-20260625-3464",
|
||||
"movies": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "霸王别姬",
|
||||
"director": "Frank Darabont",
|
||||
"year": 2004,
|
||||
"rating": 6.8,
|
||||
"duration": 179,
|
||||
"genre": "科幻",
|
||||
"actors_count": 3
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"title": "放牛班的春天",
|
||||
"director": "陈凯歌",
|
||||
"year": 2019,
|
||||
"rating": 6.7,
|
||||
"duration": 117,
|
||||
"genre": "喜剧",
|
||||
"actors_count": 5
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"title": "泰坦尼克号",
|
||||
"director": "Robert Zemeckis",
|
||||
"year": 2015,
|
||||
"rating": 9.1,
|
||||
"duration": 177,
|
||||
"genre": "爱情",
|
||||
"actors_count": 4
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"title": "三傻大闹宝莱坞",
|
||||
"director": "James Cameron",
|
||||
"year": 2024,
|
||||
"rating": 7.6,
|
||||
"duration": 117,
|
||||
"genre": "冒险",
|
||||
"actors_count": 5
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"title": "阿甘正传",
|
||||
"director": "宫崎骏",
|
||||
"year": 2016,
|
||||
"rating": 8.0,
|
||||
"duration": 146,
|
||||
"genre": "喜剧",
|
||||
"actors_count": 3
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"title": "星际穿越",
|
||||
"director": "Christopher Nolan",
|
||||
"year": 2010,
|
||||
"rating": 9.2,
|
||||
"duration": 168,
|
||||
"genre": "爱情",
|
||||
"actors_count": 2
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"title": "忠犬八公的故事",
|
||||
"director": "Lasse Hallström",
|
||||
"year": 2016,
|
||||
"rating": 9.3,
|
||||
"duration": 106,
|
||||
"genre": "悬疑",
|
||||
"actors_count": 5
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"title": "肖申克的救赎",
|
||||
"director": "Rajkumar Hirani",
|
||||
"year": 2018,
|
||||
"rating": 7.3,
|
||||
"duration": 107,
|
||||
"genre": "剧情",
|
||||
"actors_count": 4
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"title": "千与千寻",
|
||||
"director": "Christophe Barratier",
|
||||
"year": 2019,
|
||||
"rating": 7.3,
|
||||
"duration": 118,
|
||||
"genre": "动画",
|
||||
"actors_count": 4
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"title": "盗梦空间",
|
||||
"director": "Christopher Nolan",
|
||||
"year": 2008,
|
||||
"rating": 9.3,
|
||||
"duration": 111,
|
||||
"genre": "动画",
|
||||
"actors_count": 5
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user