Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 24th, 2002, 01:21 AM
estron estron is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Posts: 40 estron User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 12
urllib or httplib

Ok, Im going to get to the meat of my problem.

I have some code I've made that downloads a proxy list.

From that proxy list, I'm able to do a for proxy in proxylist to
execute code on each proxy.

Now, what I want to do, is take a proxy, connect to it and request a file from a server via that proxy. To see if it allows requests via it.

I've managed to do that with some luck. But, for some reason (which I guess could be a slow request response) the loop takes forever.

Theres only about 20 proxies in the list.
A schematic of my code so far is:

for self.proxy in self.proxy.list:
-->self.dlm = re.compile(r":")
-->self.lst = self.dlm.split(self.proxy)
-->self.remote = "http://www.example.com/~user/index.html"
-->self.proxy = self.lst[0]
-->self.conn = httplib.HTTP(self.proxy)
-->try:
-------->self.conn.putrequest("GET", self.remote)
-------->self.conn.putheader("Host", self.remote)
-------->self.conn.putheader("User-agent", "some-agent")
-------->self.conn.endheader()
-------->self.chk = self.conn.getresponse()
-------->if self.chk.status == 200:
---------------->print "Connection made!"
---------------->self.conn.close()
-->except:
-------->print "Connection FAILED!"
-------->self.conn.close()
else:
-->print "All done!"

Thats a rough idea of the code.

Basically, what i'm trying to do is connect to self.proxy, request www.example.com/~user/index.php, check to see if it returned ok (if so print a message), if it didnt return ok, print a message an go to the next proxy in the list.

What it's doing is running a few connections, then it seems to stop, I hit cntrl-c a few times(each time I do it seems to give me the Connection FAILED error), then it kicks in again but stops shortly after.

Any idea how to make this code actually work correctly?
Any help would be appreciated

Estron

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > urllib or httplib

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap