Transforming this readable code to Python 3

Asked

Viewed 46 times

0

Hi I wanted to know how I transform this legible code to Python 3`

import urllib

proxy = {'http': 'http://myproxy:port'}
print ("Using HTTP proxy %s" % proxy['http'])
urllib.urlopen('https://google.com', proxies=proxy).read()
f = urllib.urlopen('https://drrr.com', proxies=proxy).read()
print(f)

1 answer

0


Here’s an example of how to use urllib in Python 3 with the requirements you have:

from urllib.request import URLopener
proxy = {'http': 'http://myproxy:port'}
urlopener = URLopener(proxy)
content = urlopener.open('https://mywebsite.com').read()
print(content)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.