So I've been trying this for a long time and I've given up. I can't code it myself and no examples are helping. I want to log on to a website and return some text from it. The returning text part won't be hard, the logging in is the problem. For an example, could someone please give me the code to log on to this site and return the html of the page? If you could make it so that all I would have to do is replace my username and password, that would be great. I don't like other people writing my code, but its not so fun anymore, and I need it soon. Thanks!
gsingh2011 0 Junior Poster in Training
Recommended Answers
Jump to PostHey there,
The short answer is that you haven't looked hard enough. ;)
I realize that you probably don't want to hear that, so here's a quick and dirty explanation. Most sites don't like computers logging themselves into their protected areas. For this reason, they have created security …
Jump to PostHaha, I see your point. But I don't think the login scripts are going to complain if I can somehow send the correct data with the POST command... I put send some data to the server and the server verifies that that is my account and it lets me see …
Jump to Postdef get_xml(uri,login): netlock = urlparse.urlparse(uri) pswdMngr = urllib2.HTTPPasswordMgrWithDefaultRealm() pswdMngr.add_password(None,netlock[1],login.get("username"),login.get("password")) auth = urllib2.HTTPBasicAuthHandler(pswdMngr) req = urllib2.Request(uri) opener = urllib2.build_opener(auth) f = opener.open(req) xml = f.read() f.close() return xml
I used this to pull down an xml from twitter. Works nicely. login is a dictionary with username and password …
All 11 Replies

sravan953
yash_792 0 Newbie Poster
gsingh2011 0 Junior Poster in Training
jlm699 320 Veteran Poster
gsingh2011 0 Junior Poster in Training
zachabesh 5 Junior Poster
gsingh2011 0 Junior Poster in Training
zachabesh 5 Junior Poster
jlm699 320 Veteran Poster
amadain 22 Newbie Poster
zachabesh 5 Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.