I'm trying to parse HTML data of a website. I wrote this code:
import urllib.request
def parse(url):
response = urllib.request.urlopen(url)
html = response.read()
strHTML = html.decode()
return strHTML
website = "http://www.manarat.ac.bd/"
string = parse(website)
but it is showing this error:
Traceback (most recent call last): File "C:\Users\pupewekate\Videos\RAW\2.py", line 11, in
string = parse(website) File "C:\Users\pupewekate\Videos\RAW\2.py", line 5, in parse
response = urllib.request.urlopen(url) File "C:\Users\pupewekate\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py", line 223, in urlopen return opener.open(url, data, timeout) File "C:\Users\pupewekate\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py", line 532, in open response = meth(req, response) File "C:\Users\pupewekate\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py", line 642, in http_response 'http', request, response, code, msg, hdrs) File "C:\Users\pupewekate\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py", line 570, in error return > self._call_chain(*args) File "C:\Users\pupewekate\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py", line 504, in _call_chain result = func(*args) File "C:\Users\pupewekate\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py", line 650, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 412: Precondition Failed
Any solution?