1

I use python3 and urllib module has parse, error, robotparse only it does not commands like import urllib.request and urllib.request.urlopen so what the substitute or how to fix it

2 Answers2

0

go through the documentation and using it re-install the urllib and then try or you can try this script instead

 from urllib.request import urlopen
 html = urlopen("http://www.google.com/").read()
 print(html)
classicdude7
  • 903
  • 1
  • 6
  • 23
0

In general, it's recommended to use the latest python http clients - urllib3 or requests

pip3 install urllib3

pip3 install requests

If you're trying to read a a website content using its URL you can do it with requests:

import requests

response = requests.get("https://stackoverflow.com/")
print(response.text)

Roi Mor
  • 56
  • 1
  • 5