今日は、mechanicalsoup を使用して映画天堂(https://www.dytt.to)から映画のタイトル、映画、および磁力リンクを取得する例を紹介します。
import mechanicalsoup
from urllib.parse import urljoin, unquote
# Browserオブジェクトを作成
browser = mechanicalsoup.Browser()
# 映画天堂の洋画を訪問
url = "https://www.dytt.to/html/gndy/oumei/"
page = browser.get(url)
# 映画のタイトルを取得
links = page.soup.select(".ulink")
for link in links:
text = link.text.strip()
# リンクを取得
href = link.get("href")
full_url = urljoin(url, href)
# 映画のリンクを訪問
movie_page = browser.get(full_url)
# <div id="Zoom">タグを取得
zoom_div = movie_page.soup.find("div", {"id": "Zoom"})
# zoom_divが存在する場合、<a>タグのhref値を取得
if zoom_div:
a_tags = zoom_div.find_all("a")
for a_tag in a_tags:
a_href = unquote(a_tag.get("href"))
print(f"映画のタイトル:{text}\nリンク:{full_url}")
print(f"磁力ダウンロードリンク:{a_href}\n\n")
print("-----------------")
出力:
映画のタイトル:2023 年ドラマスリラー「沼泽王的女儿」BD 中英双字
リンク:https://www.dytt.to/html/gndy/dyzz/20231123/64365.html
磁力ダウンロードリンク:magnet:?xt=urn:btih&dn = 阳光电影 dygod.org. 沼泽王的女儿.2023.BD.1080P. 中英双字.mkv&tr=udp://tracker.opentrackr.org:1337/announce&tr=udp://exodus.desync.com:6969/announce
映画のタイトル:2023 年アニメコメディ「蜥蜴伯伯里奥」BD 中英双字
リンク:https://www.dytt.to/html/gndy/dyzz/20231123/64363.html
磁力ダウンロードリンク:magnet:?xt=urn:btih:699620e20227fcebbbaac4f6a76988ee59354cc1&dn = 阳光电影 dygod.org. 蜥蜴伯伯里奥.2023.BD.1080P. 中英双字.mkv&tr=udp://tracker.opentrackr.org:1337/announce&tr=udp://exodus.desync.com:6969/announce
映画のタイトル:2023 年アクション「约翰尼与克莱德」BD 英语中字
リンク:https://www.dytt.to/html/gndy/jddy/20231122/64362.html
磁力ダウンロードリンク:magnet:?xt=urn:btih:61b765ce57d2aaa58fccc8ff2b42da9445618a81&dn = 阳光电影 dygod.org. 约翰尼与克莱德.2023.BD.1080P. 英语中字.mkv&tr=udp://tracker.opentrackr.org:1337/announce&tr=udp://exodus.desync.com:6969/announce
映画のタイトル:2023 年ドラマスリラー「盲证」BD 中英双字
リンク:https://www.dytt.to/html/gndy/jddy/20231121/64359.html
磁力ダウンロードリンク:magnet:?xt=urn:btih:625c90c6d1b218a338c03ec4b3fea01c3f9fde9a&dn = 阳光电影 dygod.org. 盲证.2023.BD.1080P. 中英 双字.mkv&tr=udp://tracker.opentrackr.org:1337/announce&tr=udp://exodus.desync.com:6969/announce
映画のタイトル:2023 年ホラー「驱魔人:信徒」BD 英语中字
リンク:https://www.dytt.to/html/gndy/jddy/20231120/64357.html
磁力ダウンロードリンク:magnet:?xt=urn:btih&dn = 阳光电影 dygod.org. 驱魔人:信徒.2023.BD.1080P. 英语中字.mkv&tr=udp://tracker.opentrackr.org:1337/announce&tr=udp://exodus.desync.com:6969/announce
映画のタイトル:2023 年ドラマスリラー「男气管制」BD 中英双字
リンク:https://www.dytt.to/html/gndy/jddy/20231119/64356.html
磁力ダウンロードリンク:magnet:?xt=urn:btih:94c703906554074e3e90f9d36d839a75f3845209&dn = 阳光电影 dygod.org. 男气管制.2023.BD.1080P. 中英双字.mkv&tr=udp://tracker.opentrackr.org:1337/announce&tr=udp://exodus.desync.com:6969/announce
映画のタイトル:2023 年ドラマスリラー「男气管制」BD 中英双字
リンク:https://www.dytt.to/html/gndy/jddy/20231119/64356.html
磁力ダウンロードリンク:magnet:?xt=urn:btih:94c703906554074e3e90f9d36d839a75f3845209&dn = 阳光电影 dygod.org. 男气管制.2023.BD.1080P. 中英双字.mkv&tr=udp://tracker.opentrackr.org:1337/announce&tr=udp://exodus.desync.com:6969/announce
映画のタイトル:2023 年ドラマスリラー「男气管制」BD 中英双字
リンク:https://www.dytt.to/html/gndy/jddy/20231119/64356.html
磁力ダウンロードリンク:magnet:?xt=urn:btih:94c703906554074e3e90f9d36d839a75f3845209&dn = 阳光电影 dygod.org. 男气管制.2023.BD.1080P. 中英双字.mkv&tr=udp://tracker.opentrackr.org:1337/announce&tr=udp://exodus.desync.com:6969/announce