Ray Parrish wrote:
Hello,
I am trying to figure out how to send cookie data with an httplib
request command. Here is what the doc says -
request( method, url[, body[, headers]])
This will send a request to the server using the HTTP request
method method and the selector url. If the body argument is present,
it should be a string of data to send after the headers are finished.
The header Content-Length is automatically set to the correct value.
The headers argument should be a mapping of extra HTTP headers to send
with the request.
My question is how do I formulate a "mapping" of a header for a few
cookies? Here are the cookies I would like to send with the request -
TVGID=029690D849714243A9DDEA34652CA804; Provider=Broadcast;
__qca=P0-547310088-1271379357584;
LastGrid=fmt=0&srvid=20442&gridmins=120&gridyr=2010&gridmo=4&griddy=15&gridhr=20&chanrow=1&genre=0&favchan=false&magic=1269|9898&magictype=0&zip=&music=1&ppv=1&24hr=1&HDTVOnly=false;
s_cc=true; s_sq=%5B%5BB%5D%5D; wtpgcnt=1;
s_vi=[CS]v1|25E3DAD0050118C7-6000010E60004530[CE];
base_domain_4631b4ff1e53d450c3f9726dd45be7de=tvguide.com;
rsi_ct=2010_4_15:6;
Thanks for any help you can be, Ray Parrish
OK, I got it figured, but still no luck, passing the cookies didn't
help me get at the search results I was trying to get. Here is the code
for passing cookies -
connection = httplib.HTTPConnection("www.tvguide.com", port)
connection.putrequest("GET", "/listings/default.aspx?keyword=Star+Trek")
connection.putheader("Cookie", "TVGID=029690D849714243A9DDEA34652CA804;
Provider=Broadcast; __qca=P0-547310088-1271379357584;
LastGrid=fmt=0&srvid=20442&gridmins=120&gridyr=2010&gridmo=4&griddy=15&gridhr=20&chanrow=1&genre=0&favchan=false&magic=1269|9898&magictype=0&zip=&music=1&ppv=1&24hr=1&HDTVOnly=false;
s_cc=true; s_sq=%5B%5BB%5D%5D; wtpgcnt=1;
s_vi=[CS]v1|25E3DAD0050118C7-6000010E60004530[CE];
base_domain_4631b4ff1e53d450c3f9726dd45be7de=tvguide.com;
rsi_ct=2010_4_15:8;
rsi_segs=D04451_10006|D04451_10077|D04451_10089|D04451_10116;
__utma=208178903.2088698592.1271379370.1271389872.1271398039.3;
__utmc=208178903;
__utmz=208178903.1271398041.3.3.utmccn=(referral)|utmcsr=tvguide.com|utmcct=/search/index.aspx|utmcmd=referral;
zip=97424; ServiceID=20442; srvid=20442; ev1=star%20trek;")
connection.endheaders()
response = connection.getresponse()
headers = response.getheaders()
print headers
fileContents = response.read()
Later, Ray Parrish
--
Linux dpkg Software Report script set..
http://www.rayslinks.com/LinuxdpkgSoftwareReport.html
Ray's Links, a variety of links to usefull things, and articles by Ray.
http://www.rayslinks.com
Writings of "The" Schizophrenic, what it's like to be a schizo, and other
things, including my poetry.
http://www.writingsoftheschizophrenic.com
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor