Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_44252895
代码片段(2)
提交
4827fa41
代
代码片段(2)
项目概览
qq_44252895
/
代码片段(2)
与 Fork 源项目一致
Fork自
inscode / Python
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
代
代码片段(2)
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
4827fa41
编写于
11月 08, 2023
作者:
Q
qq_44252895
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Wed Nov 8 10:40:00 CST 2023 inscode
上级
c8222ff6
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
54 addition
and
22 deletion
+54
-22
.inscode
.inscode
+5
-1
main.py
main.py
+49
-21
电影下载/2023年剧情喜剧《偶滴神啊2》BD中英双字.torrent
电影下载/2023年剧情喜剧《偶滴神啊2》BD中英双字.torrent
+0
-0
电影下载/2023年喜剧爱情《爱犬奇缘》HD国语中字.torrent
电影下载/2023年喜剧爱情《爱犬奇缘》HD国语中字.torrent
+0
-0
未找到文件。
.inscode
浏览文件 @
4827fa41
run = "pip install -r requirements.txt;python main.py"
language = "python"
[packager]
AUTO_PIP = true
...
...
@@ -9,4 +10,7 @@ PATH = "${VIRTUAL_ENV}/bin:${PATH}"
PYTHONPATH = "$PYTHONHOME/lib/python3.10:${VIRTUAL_ENV}/lib/python3.10/site-packages"
REPLIT_POETRY_PYPI_REPOSITORY = "http://mirrors.csdn.net.cn/repository/csdn-pypi-mirrors/simple"
MPLBACKEND = "TkAgg"
POETRY_CACHE_DIR = "/root/${PROJECT_DIR}/.cache/pypoetry"
\ No newline at end of file
POETRY_CACHE_DIR = "/root/${PROJECT_DIR}/.cache/pypoetry"
[debugger]
program = "main.py"
main.py
浏览文件 @
4827fa41
import
requests
from
bs4
import
BeautifulSoup
import
re
import
os
import
base64
import
re
# 设置请求头,模拟浏览器访问
headers
=
{
'User-Agent'
:
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'
}
# 获取电影天堂最新电影页面的源代码
url
=
'https://www.dytt8.net/html/gndy/dyzz/list_23_1.html'
response
=
requests
.
get
(
url
,
headers
=
headers
)
response
.
encoding
=
'gb2312'
# 设置编码格式
html
=
response
.
text
# 使用BeautifulSoup解析网页源代码
soup
=
BeautifulSoup
(
html
,
'html.parser'
)
# 创建全局的 Session 对象
session
=
requests
.
Session
()
session
.
headers
.
update
(
headers
)
# 获取电影列表
movie_list
=
soup
.
find_all
(
'a'
,
{
'class'
:
'ulink'
})
# 遍历电影列表,获取电影名、下载链接、评分等信息
for
movie
in
movie_list
:
movie_name
=
movie
.
text
# 电影名
movie_url
=
movie
[
'href'
]
# 下载链接
# 判断电影是否已经下载过
if
not
os
.
path
.
exists
(
movie_name
):
def
download_movie
(
movie_name
,
movie_url
,
download_path
):
"""
下载电影函数
"""
movie_name
=
re
.
sub
(
r
'[\\/:*?"<>|\r\n]+'
,
''
,
movie_name
)
# 替换文件名中的特殊字符
file_path
=
os
.
path
.
join
(
download_path
,
movie_name
+
'.torrent'
)
if
not
os
.
path
.
exists
(
file_path
):
# 调用迅雷进行下载
thunder_url
=
'thunder://'
+
base64
.
b64encode
((
'AA'
+
movie_url
+
'ZZ'
).
encode
(
'utf-8'
)).
decode
(
'utf-8'
)
os
.
system
(
'start '
+
thunder_url
)
with
open
(
file_path
,
'wb'
)
as
f
:
f
.
write
(
requests
.
get
(
thunder_url
).
content
)
print
(
f
"
{
movie_name
}
下载完成!"
)
else
:
print
(
f
"
{
movie_name
}
已经下载过了!"
)
def
get_movie_list
(
session
,
url
):
"""
获取电影列表函数
"""
response
=
session
.
get
(
url
)
response
.
encoding
=
'gb2312'
# 设置编码格式
html
=
response
.
text
soup
=
BeautifulSoup
(
html
,
'html.parser'
)
movie_list
=
soup
.
find_all
(
'a'
,
{
'class'
:
'ulink'
})
return
movie_list
if
__name__
==
'__main__'
:
# 创建电影下载目录
download_path
=
os
.
path
.
join
(
os
.
getcwd
(),
'电影下载'
)
if
not
os
.
path
.
exists
(
download_path
):
os
.
makedirs
(
download_path
)
# 获取电影天堂最新电影页面的源代码
url
=
'https://www.dytt8.net/html/gndy/dyzz/list_23_1.html'
movie_list
=
get_movie_list
(
url
)
# 遍历电影列表,获取电影名、下载链接等信息
for
movie
in
movie_list
:
movie_name
=
movie
.
text
# 电影名
movie_url
=
movie
[
'href'
]
# 下载链接
# 判断电影是否已经下载过
if
not
os
.
path
.
exists
(
os
.
path
.
join
(
download_path
,
f
"
{
movie_name
}
.torrent"
)):
download_movie
(
movie_name
,
movie_url
,
download_path
)
# 打印电影信息
print
(
movie_name
,
movie_url
)
\ No newline at end of file
电影下载/2023年剧情喜剧《偶滴神啊2》BD中英双字.torrent
0 → 100644
浏览文件 @
4827fa41
电影下载/2023年喜剧爱情《爱犬奇缘》HD国语中字.torrent
0 → 100644
浏览文件 @
4827fa41
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录