0

Possible Duplicate:
Python urllib3 and how to handle cookie support?

I am trying to retrieve source code from a webpage with an already issued cookie and write the source code to a txt file. If I remove the cookies=cookie portion I can retrieve the source code but I need to somehow send the cookie with the http request.

output = open('Filler.txt', 'w+')
http = urllib3.PoolManager()
cookie =('users' , '1597413515')
r = http.request('http://google.com' , 'GET' , cookies=cookie)
output.write(r.data)
output.close()

I get a KeyError: None

Community
  • 1
  • 1
Kyle
  • 3
  • 1
  • 3

1 Answers1

1

You have to add the cookie to the header before sending the request. Have you seen Python urllib3 and how to handle cookie support?

Community
  • 1
  • 1
Dr. Jan-Philip Gehrcke
  • 33,287
  • 14
  • 85
  • 130