简体   繁体   中英

Python get JSON Response from XHR Request

I've been trying for some time to build a get request using requests and other python tools, which should actually return a JSON.

To get closer to the topic, I first try to reproduce the whole thing in the browser. Thereby I already come to limits.

It's about this URL: https://unverpackt-verband.de/map

When I look at the.network analysis in Firefox, I see the desired json under Response. But the Request section is empty. 在此处输入图像描述

Now I would appreciate help on how to find/build a suitable request to get and process this JSON in an automated way using python.


EDIT what has been tried so far:


requests.get("https://api.unverpacktverband.de/map").json() Outcome: "TooManyRedirects: Exceeded 30 redirects." Error

I'm not sure if you're looking for the following?

import requests
import pandas as pd


headers = {'accept': 'application/json, text/plain, */*',
    'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.79 Safari/537.36'
}

url = 'https://api.unverpackt-verband.de/map'

r = requests.get(url, headers=headers)

df = pd.json_normalize(r.json())
print(df)

Result in terminal:

    id  type    lat lng
0   1985    storeNoMember   47.558307   9.709220
1   1984    plannedMember   48.941530   8.405472
2   1983    storeMember 49.999355   8.711121
3   1982    mobilePlannedMember 51.838272   6.614867
4   1981    plannedMember   52.841810   7.519561
... ... ... ... ...
631 850 storeNoMember   50.713607   7.044930
632 849 storeNoMember   51.486631   7.214458
633 847 storeMember 49.898628   10.896140
634 846 storeMember 49.840614   7.861260
635 845 storeNoMember   52.201666   8.788376
636 rows × 4 columns

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM