'Python POST requests returns a "bad requests" when using a proxy
I have been testing things out using this proxy to scrape some Yelp pages. Things have been great but I had to use it for a POST request but I kept getting a 400 status code (Bad request). Here is the thing if I try it without the proxy I get the expected results. Below is the code without using the proxy
import requests
import json
# Build a suitable JSON request for the required information
json_post = [
{
"operationName": "GetBusinessAttributes",
"variables": {
"BizEncId": "1IMivcKgsN8xUL5dFKQK3w"
},
"extensions": {
"documentId": "35e0950cee1029aa00eef5180adb55af33a0217c64f379d778083eb4d1c805e7"
}
},
{
"operationName": "GetBizPageProperties",
"variables": {
"BizEncId": "1IMivcKgsN8xUL5dFKQK3w"
},
"extensions": {
"documentId": "f06d155f02e55e7aadb01d6469e34d4bad301f14b6e0eba92a31e635694ebc21"
}
},
]
r = requests.post("https://www.yelp.com/gql/batch", json=json_post)
and here is the code with the proxy
import requests
import json
# Build a suitable JSON request for the required information
json_post = [
{
"operationName": "GetBusinessAttributes",
"variables": {
"BizEncId": "1IMivcKgsN8xUL5dFKQK3w"
},
"extensions": {
"documentId": "35e0950cee1029aa00eef5180adb55af33a0217c64f379d778083eb4d1c805e7"
}
},
{
"operationName": "GetBizPageProperties",
"variables": {
"BizEncId": "1IMivcKgsN8xUL5dFKQK3w"
},
"extensions": {
"documentId": "f06d155f02e55e7aadb01d6469e34d4bad301f14b6e0eba92a31e635694ebc21"
}
},
]
r = requests.post("http://api.proxiesapi.com/?auth_key=d325db3f85a49b0561aaa0dda5209b15_sr98766_ooPq87&url=https://www.yelp.com/gql/batch", json=json_post)
I've included the auth_key so you can try it out. I have a feeling the problem in how I am passing the json. Any help will be much appreciated.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
