1

I'm trying to get a webpage using a company's API, it works perfectly in Postman but when I take the code generated by Postman into python requests it returns a different response.

I set up my proxy and added my base auth but it still won't work

url = "https://www.test.com/confluence/rest/api/content/<id>"

querystring = {"expand":"space,body.view,version,container"}

headers = {
    'Content-Type': "application/json",
    'Authorization': "****",
    'User-Agent': "PostmanRuntime/7.15.2",
    'Accept': "*/*",
    'Cache-Control': "no-cache",
    'Postman-Token': "****",
    'Host': "www.test.com",
    'Cookie': "****",
    'Accept-Encoding': "gzip, deflate",
    'Connection': "keep-alive",
    'cache-control': "no-cache"
    }

response = requests.request("GET", url, headers=headers, params=querystring, proxies=urllib.request.getproxies())

Postman returns a JSON response containing the entire webpage + ID and any other necessary info. Python returns an HTML webpage with this error embedded

JavaScript is either disabled in or not supported by the Web browser.
To continue logon, use a Web browser that supports JavaScript or enable JavaScript in your current browser.
Ardweaden
  • 857
  • 9
  • 23

1 Answers1

0

If you are trying to use a webpage that is purely renders by JavaScript, it may be useful for you to use selenium. This is a package that create a webbrowser that can render JavaScript. There are some nice documentation here : https://selenium-python.readthedocs.io/

The installation is quite long but it is worth the try.

Pitchkrak
  • 340
  • 1
  • 3
  • 11