Python中文
首页
教程
问答
标签
搜索
登录
注册
Selenium返回unknownProtocolFound
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我试图使用Firefox<em>Webdriver</em>,<em>Selenium</em>和<em>Python</em>从[this GooglePlay direct link generator][1]下载APK文件。</p> <p>问题是,当Selenium试图获取主页时,它会崩溃并显示以下错误消息:</p> <pre><code>/usr/bin/python2.7 /home/ghasemi/PycharmProjects/phorcys_watcher/main.py http://apps.evozi.com/apk-downloader/?id=com.instagram.android Traceback (most recent call last): File "/home/ghasemi/PycharmProjects/phorcys_watcher/main.py", line 7, in <module> content = google_play_download("com.instagram.android") File "/home/ghasemi/PycharmProjects/phorcys_watcher/collector.py", line 20, in google_play_download browser.get("https://apps.evozi.com/apk-downloader/?id=" + app_page_id) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 268, in get self.execute(Command.GET, {'url': url}) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 256, in execute self.error_handler.check_response(response) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: Reached error page: about:neterror?e=unknownProtocolFound&u=httpss%3A//www.adnetworkperformance.com/script/java.php%3Foption%3Drotateur%26r%3D411313%26treqn%3D1025813717%26runauction%3D1%26crr%3D168ce9d76b1a6695b12e%2CwcwHrNzGnshFns2PnM3bbcwGW8xLz-mNycwuvZjurZja3MzJfMxG_9xMX4wYns7a2YxHvshBL9xe3shbjN2J7umN6umNm-mNuN2czNw723956800778f24b2db6%26rtid%3D595b6ecb8ac19%26cbrandom%3D0.7519066097934798%26cbtitle%3DAPK%2520Downloader%2520%255BLatest%255D%2520Download%2520Directly%2520%257C%2520Chrome%2520Extension%2520v3%2520%28Evozi%2520Official%29%26cbiframe%3D0%26cbWidth%3D1280%26cbHeight%3D717%26cbdescription%3DDownload%2520APKs%2520Directly%2520From%2520Google%2520Play%2520To%2520Your%2520Computer%2520With%2520APK%2520Downloader%2520Extension%2520For%2520Google%2520Chrome%26cbkeywords%3D%26cbref%3D&c=&f=regular&d=Firefox%20doesn%E2%80%99t%20know%20how%20to%20open%20this%20address%2C%20because%20one%20of%20the%20following%20protocols%20%28httpss%29%20isn%E2%80%99t%20associated%20with%20any%20program%20or%20is%20not%20allowed%20in%20this%20context. </code></pre> <p>异常在此行引发: 浏览器.get(“<a href="https://apps.evozi.com/apk-downloader/?id=com.instagram.android" rel="nofollow noreferrer">https://apps.evozi.com/apk-downloader/?id=com.instagram.android</a>”)</p> <p>正如您在上面看到的,这个错误的来源是selenium试图下载它的页面中的一个错误链接。我找到了导致此错误的帧:</p> ^{pr2}$ <p>如您所见,网页开发人员错误地(两次)将<code>httpss</code>而不是{<cd2>}放错了。</p> <p>我怎么处理这个问题?</p> <p><strong>更新:</strong></p> <p>我的刮板:</p> <pre><code>import requests from lxml import html from pyvirtualdisplay import Display from selenium import webdriver def google_play_download(app_page_id): browser = webdriver.Firefox() browser.get("https://apps.evozi.com/apk-downloader/?id=" + app_page_id) browser.find_element_by_css_selector(".btn.btn-primary.btn-lg.btn-block").click() apk_link = browser.find_element_by_css_selector(".btn.btn-success.btn-block").get_attribute('href') browser.quit() for rnd in range(5): resp = requests.get(apk_link) if resp.headers['Content-Length'] == str(len(resp.content)): return resp.content if __name__ == "__main__": content = google_play_download("com.instagram.android") f = open('./file', 'wb') f.write(content) f.close() [1]: https://apps.evozi.com/apk-downloader/ </code></pre>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>一个解决方案是一个url解析函数,您可以在之前调用每个url驱动程序。获取(url)</p> <pre><code>def url_parser(url): if 'httpss' in url: url = url.replace('httpss','https') return url </code></pre> <p>你就这样用吧</p> ^{pr2}$
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
当用户用PYTHON设置一个或一个不带值的URL时,他们怎么能输入一个/a的代码呢?
1 回答
当用户登录到站点时,如何显示不同的导航栏
4 回答
当用户登录时,在Flask中向用户显示处理结果
10 回答
当用户的Flask会话结束时,我如何从Redis后端中移除所有Celery结果?
8 回答
当用户的Okta配置文件字段当前为blan时,更新该字段
1 回答
当用户的付款逾期2天时,从Django模型检索数据
4 回答
当用户的消息以问号结尾时,如何让机器人说些什么?
5 回答
当用户的系统上可能也安装了Python 2.7时,如何在用户的系统上运行Python 3脚本?
6 回答
当用户确定打印数量时,使用Matplotlib打印动画
1 回答
当用户离开时是否可以删除整个网页?
9 回答
当用户给出一个单词时如何打印?
9 回答
当用户继续更改TKin中的值(使用trace方法)时,使用Entry并更新输入的条目
3 回答
当用户编辑表单字段时,从Django时间字段中删除秒数
7 回答
当用户被更改时,消息不会来自web套接字
2 回答
当用户访问表单时,如何使表单为只读,而不具有更改权限
3 回答
当用户试图更改对象的值时,使用描述符类引发RuntimeError
2 回答
当用户调整GUI的大小时,是否有方法更改GUI内容的大小?
6 回答
当用户调整风的大小时,pythontkinter小部件的大小会不均匀
2 回答
当用户购买某个类别时,是否查找其他类别的销售?
3 回答
当用户转到上一页时,Django和芹菜插入操作
3 回答