Fetch a website (Python)
Versie door Jeroen Strompf (overleg | bijdragen) op 4 feb 2019 om 21:49 (Nieuwe pagina aangemaakt met '<pre> #! /usr/bin/python3 # # Download Channable-XML-file - Strompf, Feb. 2019 ############################################################################## # impo...')
#! /usr/bin/python3 # # Download Channable-XML-file - Strompf, Feb. 2019 ############################################################################## # import urllib.request url = 'https://www.example.com/fr-fr_channable.xml' response = urllib.request.urlopen(url) data = response.read() # a `bytes` object text = data.decode('utf-8') # a `str`; this step can't be used if data is binary print(text)