1

I pay for access to website www.publicdata.com and I am trying to create a python program to help with my queries. Unfortunately, I keep getting a blank list of cookies while using the requests module. For security reasons I cannot share my credentials but the website has a demo link that can be used to see what I am talking about.

I have checked the cookies in the browser and they show up after I login but I can't seem to get them through requests.

Here is the publicdata api for login: http://www.publicdata.com/pdapidocs/pdlogindocs.php

Here is my code:

import requests

url = "https://login.publicdata.com/pdmain.php/Logon/checkAccess"
login_data = {'login_id': 'myuser', 'password': 'mypass'}

s = requests.Session()
r = s.post(url, data=login_data, allow_redirects=True)
r2 = s.get("http://demosrch.publicdata.com")

print(r.cookies.get_dict())
print(r2.cookies.get_dict())
print(r.headers)
print(r2.headers)

demo_url = "http://demosrch.publicdata.com"

I expect the cookies to be retrieved. In the demo url the cookie it sets is called JSESSIONID.

Ivan Vinogradov
  • 4,269
  • 6
  • 29
  • 39
mindw
  • 21
  • 1
  • Did you check this [How to save requests (python) cookies to a file?](https://stackoverflow.com/q/13030095/6194097) question and usage after cookie in [How to send cookies in a post request with the Python Requests library?](https://stackoverflow.com/q/7164679/6194097) question... – Kushan Gunasekera Jul 16 '19 at 05:44
  • @Ivan Vinogradov thank you so much for formatting the question, I really appreciate it. I am going to check out the websites you mentioned and reply back here. – mindw Jul 16 '19 at 15:26

0 Answers0