0

I've written a short script and I have a chance to improve it if I get access to the certain data presented on screen. Is it possible somehow to requests this data with requests library? I need to get a user with a particular id which I gather with my 2nd script. I just need to know if it is possible because I could not find any answer on that.

enter image description here

This is the code. Link comes from headers tab:

import requests

url = "https://www.thecrims.com/api/v1/nightclub"    
payload = {"id":"17713682"}

r = requests.post(url, params=payload)
Nazim Kerimbekov
  • 4,712
  • 8
  • 34
  • 58
m3fju96
  • 1
  • 5
  • 1
    Welcome to stackoverflow. It would increase the likelihood of better responses to your questions if you included the relevant code in your question. Your screenshot just show some json in a web console. Do you want to get some user's information through a database request or by scraping a website? – pastaleg Dec 14 '19 at 21:45
  • @pastaleg I have selenium script to automate one website. I need to scrape data from preview - user info basing on id. I want to do it with requests library or rather get to know if it is possible because it is not and there is another way to do it ? – m3fju96 Dec 14 '19 at 21:49
  • Okay! So you have a website that itself is doing a HTTP request and you want to intercept the response in selenium to get the object? – pastaleg Dec 14 '19 at 22:05
  • @pastaleg showed some code – m3fju96 Dec 14 '19 at 22:12
  • Thanks! Well your code looks fine. The API returns 401 which means unauthorized. So add your relevant credentials to the request and you should be fine. This answers shows how to do that https://stackoverflow.com/questions/26745462/basic-authentication-not-working-with-requests-library – pastaleg Dec 14 '19 at 22:23

1 Answers1

0

The solution is simple, try this:

print(r.json())
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 06 '22 at 21:15