I'm trying to scrape some data from a web page and put it into a pandas dataframe. I tried and read many things but I just cannot get what I want. And I want a dataframe with all the data in separate columns and rows. Below is my code.
import requests
import json
import pandas as pd
from pandas.io.json import json_normalize
r = requests.get('http://www.starcapital.de/test/Res_Stockmarketvaluation_FundamentalKZ_Tbl.php')
a = json.loads(r.text)
res = json_normalize(a)
##print(res)
df = pd.DataFrame(res)
print(df)
##df = pd.read_json(a)
##print(df)
pd.read_json(a)
doesn't seem to work in any way. Could someone give it a try?
Thanks for all the help in advance.
Best regards, David
Or, more simply:
And one step simpler than Justin's (already helpful) response...by putting .json() at the end of the
r = requests.get
lineyou can do it this way:
Result: