如何基于 Python 的一些库下载 rmdown 的种子

324 天前
 xinmans

https://www.rmdown.com/link.php?hash=232416715dfa1b4fa7c38fa3d187c664446ae57be3c

看起来做了一些防盗链的工作

967 次点击
所在节点    Python
6 条回复
xinmans
324 天前
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
import pyperclip
from fake_useragent import UserAgent

from random import randint

from selenium.webdriver.chrome.options import Options
from selenium.webdriver import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.wait import WebDriverWait
from selenium.common.exceptions import TimeoutException


def get_random_user_agent():
ua = UserAgent()
user_agent = ua.random
headers = {"User-Agent": user_agent}
return headers


# 设置 Chrome 浏览器路径和 options
s = Service("/usr/local/bin/chromedriver")
chrome_options = Options()
torrents_path = "./"
prefs = {'savefile.default_directory': torrents_path}
chrome_options.add_experimental_option('prefs', prefs)
chrome_options.add_argument('--headless=new')
user_agent = get_random_user_agent()['User-Agent']
chrome_options.add_argument(f'user-agent={user_agent}')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('--aggressive-cache-discard')
chrome_options.add_argument('--disable-cache')
chrome_options.add_argument('--disable-application-cache')
chrome_options.add_argument('--disable-offline-load-stale-cache')
chrome_options.add_argument('--disable-gpu-shader-disk-cache')
chrome_options.add_argument('--media-cache-size=0')
chrome_options.add_argument('--disk-cache-size=0')
chrome_options.add_experimental_option("excludeSwitches", ['enable-automation', 'enable-logging'])
driver = webdriver.Chrome(service=s, options=chrome_options)

# 访问 RMDown 网站并点击复制按钮
url = 'https://www.rmdown.com/link.php?hash=232416715dfa1b4fa7c38fa3d187c664446ae57be3c'
driver.get(url)
time.sleep(2) # 等待页面加载

try:
driver.get(url)
time.sleep(2) # 等待页面加载
driver.find_element(
"xpath", "//button[@type='submit'][@title='Download file']").click()
time.sleep(2) # 等待页面加载
driver.maximize_window()
driver.quit()
except Exception as e:
print(" Connected failure: %s" % e)

# 关闭浏览器
driver.quit()


总是报错
elboble
324 天前
好像去掉 232 就是 magnet
Trim21
324 天前
把 url query 的 hash 去掉前三个字符就能拼出磁链了
xinmans
321 天前
@Trim21 没懂,hash 直接转换成 magnet ?
xinmans
321 天前
@elboble 这么神奇?
xinmans
321 天前
@xinmans 懂了

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/947106

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX