I am trying to get the data from this website, https://en.macromicro.me/charts/947/commodity-ccfi-scfi ,
I understand that the data is called from an API, how do I find out how the call is made and how do I extract it using python?
I am new to python and html in general so I have no idea where to start.
I tried,
import requests
from bs4 import BeautifulSoup
import json
import pandas as pd
urlheader = {
"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",
"Accept": "application/json, text/javascript, */*; q=0.01",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en-US,en;q=0.9",
"Authorization": "Bearer 640eabc473294fbac27930ef08d28ab4",
"Connection": "keep-alive",
"Cookie": "PHPSESSID=5q99iuiarvf1ba2lafh6je5hr5; _ga=GA1.2.628840989.1624431403; _gid=GA1.2.146418174.1624431403; _fbp=fb.1.1624431403269.1337227854; _hjTLDTest=1; _hjid=89fd1c1b-93a7-4da9-bf90-46efcb6aae15; _hjFirstSeen=1",
"DNT": "1",
"Host": "en.macromicro.me",
"Referer": "https://en.macromicro.me/charts/947/commodity-ccfi-scfi",
}
url = "https://en.macromicro.me/charts/data/947"
req = requests.post(url,headers=urlheader)
soup = BeautifulSoup(req.content, "lxml")
print(soup)
But I get the following error
<html><body><p>{"status":"Method Not Allowed","code":405,"text":"HTTP 405 (POST \/charts\/data\/947)","level":0}</p></body></html>