python - 我将如何使用 python3 在网站中查找特定链接
问题描述
我正在尝试构建一个抓取该网站的 python 程序:(https://fitgirl-repacks.site/dungeon-defenders-awakened/),然后只返回 1337x 下载链接:(https://1337x.to /torrent/4474599/Dungeon-Defenders-Awakened-v1-0-0-17001-MULTi8-FitGirl-Repack/)。我成功抓取了网站,但是我将如何编写找到 1337x 下载链接的程序:(https://1337x.to/torrent/4474599/Dungeon-Defenders-Awakened-v1-0-0-17001 -MULTi8-FitGirl-Repack/ ),并在 python 控制台中返回它?
解决方案
使用 BeautifulSoup 您可以提取网址:
from requests import get
from bs4 import BeautifulSoup
response = get('https://fitgirl-repacks.site/dungeon-defenders-awakened/')
html_text = response.text
html = BeautifulSoup(html_text)
tags = html.find_all("a", string="1337x")
first_tag = tags[0]
print(first_tag['href'])
推荐阅读
- macos - 如何从 Mac OS (Catalina) 中的“其他”存储中删除文件?
- android - adb 服务器版本 (40) 与此客户端 (41) 不匹配
- php - 在 laminas mezzio 中从具有多个路由的单个类加载不同的方法
- mysql - 以条件作为子查询的 DROP INDEX(更改表)
- html - 跨度和边界底部之间的多余空间
- python - BeautifulSoup 文本提取在锚标记的情况下将文本分解为更多行 - Python
- python - Pandas 根据条件对元素求和
- node.js - 我想从linkedin api响应中选择'displayImage~'
- keras - 深度 Q 学习的自定义损失函数
- laravel - yajra laravel 数据表返回 json 表,其中的行与查询生成器输出的顺序不同