I'm trying to log in with python Selenium to a webpage that wants authentication credentials.
Unlike the example here
my username is an email address, so it contains the '@' character (and I'm using Python).
from selenium import webdriver
driver = webdriver.Firefox()
webpage = 'http://somewhere.com/cgi-bin/dirwrap.cgi?template=template&path=news'
username = 'myname@mymailbox.com'
password = 'mypassword'
url = username + ':' + password + '@' + webpage
print(url)
driver.get(url)
output is
myname@mymailbox.com:mypassword@http://somewhere.com/cgi-bin/dirwrap.cgi?template=template&path=news
Traceback (most recent call last):
File "question.py", line 12, in <module>
driver.get(url)
File "/anaconda3/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 324, in get
self.execute(Command.GET, {'url': url})
File "/anaconda3/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 312, in execute
self.error_handler.check_response(response)
File "/anaconda3/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: Message: Malformed URL: myname@mymailbox.com:mypassword@http://somewhere.com/cgi-bin/dirwrap.cgi?template=template&path=news is not a valid URL.
I believe the problem is from the extra '@' character. How do I put it in without creating a malformed URL?