Seite 1 von 1

Öffnen Website via Python Verbindungsproblem

Verfasst: Sonntag 9. Oktober 2016, 07:03
von PythonsPalace
Moin, habe da eine Anfängerfrage:

Beim Öffnen meines FF-Browsers via Python Console erhalte ich die Fehlermeldung "Fehler - ungültige Adresse".
Das Traceback meldet : # Browser has exited 98 raise WebDriverException(...
WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.

Das Problem wird ja beschrieben, ich weiß allerdings nicht, wo z.b. dieser FF Binary Constructor ist und wie ich weiter vorgehen soll.
Danke für eure Hilfe!

Re: Öffnen Website via Python Verbindungsproblem

Verfasst: Sonntag 9. Oktober 2016, 09:00
von BlackJack
@PythonsPalace: Wie öffnest Du denn den Browser? Über das `webbrowser`-Modul aus der Standardbibliothek? Wie sieht der Aufruf genau aus? Und der Traceback?

Re: Öffnen Website via Python Verbindungsproblem

Verfasst: Sonntag 9. Oktober 2016, 09:50
von Dav1d
BlackJack hat geschrieben:@PythonsPalace: Wie öffnest Du denn den Browser? Über das `webbrowser`-Modul aus der Standardbibliothek? Wie sieht der Aufruf genau aus? Und der Traceback?
Sieht mir nach selenium aus.

Re: Öffnen Website via Python Verbindungsproblem

Verfasst: Sonntag 9. Oktober 2016, 10:13
von PythonsPalace
Es ist tatsächlich Selenium... Wollte eine Übungsaufgabe durchführen...

Code: Alles auswählen

import time
from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://inventwithpython.com')
try:
    elem = browser.find_element_by_class_name('bookcover')
    print('Found <%s> element with that class name!' % (elem.tag_name))
except:
        print('was not able to find')

Re: Öffnen Website via Python Verbindungsproblem

Verfasst: Sonntag 9. Oktober 2016, 10:14
von PythonsPalace
TRACEBACK:

---------------------------------------------------------------------------
WebDriverException Traceback (most recent call last)
<ipython-input-2-fa5c2e0086a2> in <module>()
1 import time
2 from selenium import webdriver
----> 3 browser = webdriver.Firefox()
4 browser.get('http://inventwithpython.com')
5 try:

C:\Users\Björn\Anaconda3\lib\site-packages\selenium\webdriver\firefox\webdriver.py in __init__(self, firefox_profile, firefox_binary, timeout, capabilities, proxy, executable_path, firefox_options)
78
79 executor = ExtensionConnection("127.0.0.1", self.profile,
---> 80 self.binary, timeout)
81 RemoteWebDriver.__init__(
82 self,

C:\Users\Björn\Anaconda3\lib\site-packages\selenium\webdriver\firefox\extension_connection.py in __init__(self, host, firefox_profile, firefox_binary, timeout)
50 self.profile.add_extension()
51
---> 52 self.binary.launch_browser(self.profile, timeout=timeout)
53 _URL = "http://%s:%d/hub" % (HOST, PORT)
54 RemoteConnection.__init__(

C:\Users\Björn\Anaconda3\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py in launch_browser(self, profile, timeout)
66
67 self._start_from_profile_path(self.profile.path)
---> 68 self._wait_until_connectable(timeout=timeout)
69
70 def kill(self):

C:\Users\Björn\Anaconda3\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py in _wait_until_connectable(self, timeout)
97 # Browser has exited
98 raise WebDriverException(
---> 99 "The browser appears to have exited "
100 "before we could connect. If you specified a log_file in "
101 "the FirefoxBinary constructor, check it for details.")

WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.