0

I want to extract a data table from a website. Pandas read_html is giving a HTTP error 403. Is there any other module through which I can extract the data by python.

Here is the website: https://pakstockexchange.com/stock2/index_new.php?section=research&page=show_price_table_new&symbol=ABOT

1 Answer 1

2

Mask your session as if you were using a browser:

import requests header = { "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36", "X-Requested-With": "XMLHttpRequest" } r = requests.get(url, headers=header) dfs = pd.read_html(r.text) 
Sign up to request clarification or add additional context in comments.

2 Comments

It does a perfect job of reading page, but I just want it to read the data table. Any way to achieve that?
Got the solution dfs=dfs[6] does the job.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.