user294241
user294241

Reputation: 11

error: Error -3 while decompressing data: incorrect header check

My web scraping code shown here gives the following error:

Error -3 while decompressing data: incorrect header check

Why, and how can I fix it?

import urllib.request
import zipfile
import pandas as pd
from bs4 import BeautifulSoup
import requests
import os
head = {'Accept-Encoding': 'gzip'}
BHAVCOPY_URL = "https://www.bseindia.com/markets/MarketInfo/BhavCopy.aspx"
html = requests.get(BHAVCOPY_URL, headers=head)

Upvotes: 1

Views: 335

Answers (1)

bigbounty
bigbounty

Reputation: 17408

In [36]:  headers = {"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gec
    ...: ko) Chrome/83.0.4103.97 Safari/537.36"}

In [37]: import urllib.request
    ...: import zipfile
    ...: import pandas as pd
    ...: from bs4 import BeautifulSoup
    ...: import requests
    ...: import os
    ...:
    ...: BHAVCOPY_URL = "https://www.bseindia.com/markets/MarketInfo/BhavCopy.aspx"
    ...: html = requests.get(BHAVCOPY_URL, headers=headers)

Upvotes: 1

Related Questions