2

Folks,

I am working on a scraping script which is running once a day where I need to re-authenticate my account.

First I have to login and then only I can see the page. Like normal page login and scrapping this won't work (read in articles and used the code below as suggested on most of the blogs and forumns) This still doesn't work.

It's an https website.

URL: https://www2.somewebsite.com/mypage.php

enter image description here enter image description here

Now I have this code:

def InitializeBrowser():
    browser = webdriver.Firefox()
    browser.set_window_size(1120, 550)
    return browser

def CheckTest(request):
    browser = InitializeBrowser()
    data = browser.get("https://gitroix:Ju2R4kmb@www2.sfmx.org/camera.php")
    alert = browser.switch_to_alert()
    alert.accept()
    browser.close()
    return HttpResponse(data.contents)

However the above code doesn't fills in the data in popup box fields, not clicks on Login.

What would be the issue?

EDIT 1:

I did tried this from How to Submit HTTP authentication with Selenium python-binding webdriver

But no success either.

profile = webdriver.FirefoxProfile()
profile.set_preference('network.http.phishy-userpass-length', 255)
driver = webdriver.Firefox(firefox_profile=profile)
driver.get("https://username:password@somewebsite.com/")
Community
  • 1
  • 1
Django Anonymous
  • 2,987
  • 16
  • 58
  • 106
  • provided image is not the `Firefox`, but `Safari` dialog box... how it actually looks like in your case? – Andersson Feb 12 '16 at 08:58
  • @Andersson Just posting firefox image also. A moment. – Django Anonymous Feb 12 '16 at 09:00
  • 1
    got the same case and tried the same thing on normal http protocol with firefox. `browser.switch_to_alert` is not executed at all. The code got stuck at `browser.get`. – chfw Aug 10 '16 at 15:26
  • @DjangoAnonymous Are you able to resolve above problem? I have also facing the same issue and not able to resolve it. This code is not working in my case driver.get("https://username:password@testwebsite.com/testpage.html") – Shoaib Akhtar Nov 17 '16 at 10:36

1 Answers1

1

This works for me:

driver = webdriver.Firefox()
driver.get("https://username:password@testwebsite.com/testpage.html")
driver.implicitly_wait(30)
Saurabh Shrivastava
  • 1,394
  • 4
  • 21
  • 50