1
xinmans OP 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() 总是报错 |
2
elboble 2023-06-08 23:14:55 +08:00 via Android
好像去掉 232 就是 magnet
|
3
Trim21 2023-06-08 23:26:57 +08:00
把 url query 的 hash 去掉前三个字符就能拼出磁链了
|