Quantcast

Jump to content


Photo

a little python help?


  • Please log in to reply
7 replies to this topic

#1 WhiteRabbit

WhiteRabbit
  • 86 posts

Posted 21 July 2010 - 03:45 PM

Ok so thus far I understand what's happening... but when I tested it it doesn't seem to be working correctly... anyone know what wrong?

the code logs in then should visit the links in the text file... it's reading them in right but im not recieving the neopoints like i should...

anything look wrong with this code?

f=open('/home/user/Desktop/linklist.txt', 'r')
line = ""
i=0
while 1==1:
	i=i+1	
	print i	
	time.sleep(12)
	line=f.readline()
	if len(line) == 0:
		break
	print line	
	url=line
	request = urllib2.Request(url)
	page = opener.open(request)

Edited by WhiteRabbit, 21 July 2010 - 05:11 PM.


#2 Waser Lave

Waser Lave

  • 25516 posts


Users Awards

Posted 21 July 2010 - 04:10 PM

Try just using code instead of codebox and it might format properly.

#3 ShadowLink64

ShadowLink64
  • 16735 posts


Users Awards

Posted 22 July 2010 - 10:58 AM

Have you packet sniffed to see if you're even sending the page requests properly? Use Wireshark or something to check if you're sending the requests properly.

If not, try using the sample code here to use urllib2 in a different way: http://diveintopytho.../redirects.html

Also you might want to add f.close() at the very end so the URL file isn't locked anymore, but it's not really that important I guess. :p

#4 iomega

iomega
  • 1070 posts


Users Awards

Posted 22 July 2010 - 07:04 PM

EDIT: my bad. i should learn to read first >_<

EDIT 2:

while 1==1
are you sure that's right?

Edited by iOmega, 22 July 2010 - 07:07 PM.


#5 WhiteRabbit

WhiteRabbit
  • 86 posts

Posted 23 July 2010 - 12:30 AM

ShadowLink64 thanks for the suggestion on wireshark i barely ever use it as i dont program to many network things...

and iomega it should break out of that loop at the end of the file... len(line)==0 and besides that i've been letting it run for about 30 minutes then killing it and checking my account about 10 mins later and it didnt give me anything...

#6 aweroij

aweroij
  • 44 posts

Posted 24 July 2010 - 07:38 PM

Don't you need cookies?

#7 Hydrogen

Hydrogen
  • Neocodex Co-Founder

  • 22213 posts


Users Awards

Posted 24 July 2010 - 09:33 PM

Don't you need cookies?

If you're doing anything on neopets you probably do need cookies.

Also you can just do:
while True:
for line in f:


#8 WhiteRabbit

WhiteRabbit
  • 86 posts

Posted 26 July 2010 - 09:11 AM

Sorry I probably should have stated that's just a code excerpt and there is no problem with it... i was just being to impatient and need to retest the links in the link list...

also thanks hydrogen for the for statement!


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users