Indika Rajapaksha
Indika Rajapaksha

Reputation: 1168

"requests-html" proxy setting not working

I'm using the following code to set the proxy for the HTMLSession, get() method. Still, it uses my IP instead of the proxy IP.

proxy string format:

http://username:password@ip:port

r = session.get('https://whatismyipaddress.com/', proxies={'http': proxy})
r.html.find('p.ip-address')[0].text

above print the following which is my current IP address.

'IPv4:? The most common IP version is assigned by ISPs. 175.157.?.?'

Upvotes: 1

Views: 2545

Answers (1)

Dorian Massoulier
Dorian Massoulier

Reputation: 564

You need to add 'https' in proxies:

proxy = 'http://username:password@ip:port'
r = session.get('https://whatismyipaddress.com/', proxies={'http': proxy, 'https': proxy})

Upvotes: 2

Related Questions