1

I'm relatively new to python and have just started using some of the web functions. But it seems regardless of what I do I can't get a web page to open (url open), and copy the contents to a text file.

from urllib.request import urlopen
url = https://en.wikipedia.org/wiki/Main_Page
web_page = urlopen(url)
web_page_bytes = web_page.read()
web_page_text = web_page_bytes.decode('UTF-8')
filename = 'download.html'
html_file = open('download.html', 'w', encoding = 'UTF-8')
html_file.write(web_page_text)

It seems regardless of what I do, I can't get anything to open or download. Am I doing something wrong in the coding, or could it be something software related. (using MacOS) Any help would be appreciated.

SkinnyBetas
  • 461
  • 1
  • 5
  • 27

0 Answers0