I'm trying to scrape this site and I get 403 code its the first time I've had this code when web scraping and I don't really understand what I have to do to solve it. I think maybe I can use Selenium to scrape the page, but I wonder if its possible to get the AJAX response and get the JSON as a return. If its not possible to get a return could I get an explaination of why? Thanks.
Here is my code:
import requests
url = 'https://public-api.pricempire.com/api/item/loadGraph/14/1140'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36'
}
r = requests.get(url, headers=headers)
print(r.status_code)
Code generated from cURL insomnia
import requests
url = "https://public-api.pricempire.com/api/item/loadGraph/14/875"
payload = ""
headers = {
"authority": "public-api.pricempire.com",
"pragma": "no-cache",
"cache-control": "no-cache",
"sec-ch-ua": "^\^"
}
response = requests.request("GET", url, data=payload, headers=headers)
print(response.text)
First two times I ran it, it gave me status 200, but afterwards it gives me 403, I'm trying to figure out why and I just don't know.