urllib2 with cookies

前端 未结 2 2027
暗喜
暗喜 2021-01-05 15:35

I am trying to make a request to an RSS feed that requires a cookie, using python. I thought using urllib2 and adding the appropriate heading would be sufficient, but the re

2条回答
  •  情深已故
    2021-01-05 15:57

    import urllib2
    opener = urllib2.build_opener()
    opener.addheaders.append(('Cookie', 'cookiename=cookievalue'))
    f = opener.open("http://example.com/")
    

提交回复
热议问题