I currently have a little script that loads a webpage and retrieves some data that interests me. Nothing unusual.
I am currently loading the page as follows:
import commands
command = 'wget --output-document=- --quiet --http-user=USER --http-password=PASSWORD https://www.example.ca/page.aspx'
status, text = commands.getstatusoutput(command)
Although this works just fine, I thought it made sense to remove the wget dependency. I thought it should be trivial to convert above to urllib2, but so far I have had zero success. The Internet are complete examples of urllib2, but I did not find anything that matched my need for simple authentication of an HTTP username and password with an HTTPS server.
source
share