I want to write a python script which downloads the web-page only if the web-page contains HTML. I know that content-type in header will be used. Please suggest someway to do it as i am unable to get a way to get header before the file download.
I want to write a python script which downloads the web-page only if the
Share
Use
http.clientto send aHEADrequest to the URL. This will return only the headers for the resource then you can look at thecontent-typeheader and see if ittext/html. If it is then send aGETrequest to the URL to get the body.