如何使用 python 自动执行此下载提示? [英] How to automate this downloading prompt using python?

查看:35
本文介绍了如何使用 python 自动执行此下载提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个爬虫,用于使用 selenium 和 python 从特定的 torrent 站点下载 torrent.当有人点击磁铁下载"时,就会发生下载.链接并单击打开 μtorrent".所以点击磁铁下载"后它将打开一个弹出窗口(不是 javascript 弹出窗口),并且必须单击打开 μtorrent".如何自动执行此步骤?我附上下面的图片.请帮助我.我在堆栈中寻找解决方案,但没有一个答案对我有帮助.

I made a crawler for downloading torrent from a specific torrent site using selenium and python. The download will happen when someone clicks on the "magnet download" link and click on the "open μtorrent". So after clicking on the "magnet download" it will open a pop-up(which is not a javascript pop-up) and has to click on the "open μtorrent". How can I automate this step? I am attaching the image below. Please help me in this. I have looked for the solutions in stack but none of the answers helped me.

推荐答案

您可以使用配置文件本身禁用它

You can disable it using the profile itself

from selenium import webdriver
chrome_options.add_experimental_option("prefs", {'protocol_handler.allowed_origin_protocol_pairs': 
{"https://www.1377x.to":{"magnet": True}}})
d = webdriver.Chrome(options=chrome_options)
d.get("http://example.com/url/to/magnet/site")
elem = d.find_element_by_css_selector("a[href*=magnet]")
elem.click()

这篇关于如何使用 python 自动执行此下载提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆