Accessing web site with cookies - help need
Miki Tebeka
tebeka at cs.bgu.ac.il
Thu Aug 16 03:21:29 EDT 2001
Hello All,
Ok, I'm dumb.
I've been reading about accessing html pages and cookies and tried to
retrieve
some web pages from the sites:
http::/www.themarker.co.il
But I can't get through. (All I get is the the login page)
So far what I did:
import httplib
import base64
import string
h = httplib.HTTP('www.themarker.co.il')
h.putrequest('GET',
'/ibo/article.jhtml?ElementId=%2Fibo%2Frepositories%2Fstories%2Fm1_2000%2Fgb
20010815_1.xml&origin=ibo&layer=hp&layer2=&layer3=')
userid = 'my-user-id'
passwd = 'my-password'
auth = 'Basic ' + string.strip(base64.encodestring(userid + ':' + passwd))
h.putheader('Authorization', auth )
h.putheader('Cookie', 'NGUserID=ac15011f-5001-997078050-1') # this one I got
from the Windows Cookie directory
h.endheaders()
errcode, errmsg, headers = h.getreply()
if (errcode == 200):
f = h.getfile()
data = f.read() # Get the raw HTML
f.close()
print data
else:
print "Can't access file"
--
Bye.
----------------------------------------------------------------------------
-
Smile, damn it, smile.
lambda msg: {
'name' : 'Miki Tebeka',
'email' : 'mikit at elrontelesoft.com',
'url' : 'http://www.cs.bgu.ac.il/~tebeka',
'quote' : 'The only difference between children and adults is the
price of the toys'
}[msg]
More information about the Python-list
mailing list