問題は、セレンはホームページを取得しようとしたとき、それは次のエラーメッセージでクラッシュし、ということである: browser.get(「https://apps.evozi.com/apk-downloader/?id=com.instagram.android」):
例外は、この行にスロー/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.
上記のように、このエラーの原因はセレンがダウンロードしようとしているページの間違ったリンクです。あなたが見ることができるように
<iframe width="468" height="60" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" allowfullscreen="true" style="border: medium none; padding: 0; margin: 0;" sandbox="allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-pointer-lock allow-same-origin" id="595b6e88086f8" frameborder="0" src="httpss://www.adnetworkperformance.com/script/java.php?option=rotateur&r=411313&treqn=501505383&runauction=1&crr=fc25086f39dc3c58bbdbGJTJyVGZh9Gbud3bk1yawFmRyUSbvNmLpp3b2VmLzBHchZkMlYkMlE0MlMHc0RHa2dfe473f7c304fd8fb65&rtid=595b6e88086f8&cbrandom=0.6676681852413189&cbtitle=APK%20Downloader%20%5BLatest%5D%20Download%20Directly%20%7C%20Chrome%20Extension%20v3%20(Evozi%20Official)&cbiframe=0&cbWidth=1522&cbHeight=741&cbdescription=Download%20APKs%20Directly%20From%20Google%20Play%20To%20Your%20Computer%20With%20APK%20Downloader%20Extension%20For%20Google%20Chrome&cbkeywords=&cbref=" scrolling="no"></iframe>
、Webページの開発者が(2回!)誤って代わりにhttps
のhttpss
を置く:私はこのエラーの原因となるフレームを見つけました。
この問題はどのように処理できますか?
更新:
マイスクレーパー:
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/
ドライバ自体が私ではなくバグのあるURLを取得しようとしています。私はドライバを使用して正しいURLを取得します。この正しいURLの応答には、ドライバがダウンロードしてブームしようとするいくつかのリンク(例えば画像)と_iframe_sがあります! – Abraham
スクレイパーコードを貼り付けることができますか?それでは、urlパーサ関数の使用場所を教えてください。 links-loopに何らかのリンクが必要です.WebdriverにURLを送ってください... – jlaur
更新を確認してください。 – Abraham