PDA

View Full Version : [Python] Damn URLError!



Neoquest
02-04-2012, 02:27 AM
I've totally finished writing a Cliffhanger AP. Totally. The last thing that I put together was the post request to submit my answer to the question and I always get the same error!



Traceback (most recent call last):
File "C:\Python27\Doc\Neopets\CliffHangerAP.py", line 157, in <module>
clif = opener.open(request)
File "C:\Python27\lib\urllib2.py", line 392, in open
req = meth(req)
File "C:\Python27\lib\urllib2.py", line 1100, in do_request_
raise URLError('no host given')
URLError: <urlopen error no host given>


My code is simply:


clif = opener.open(request)

The request in one case was:


[Only registered and activated users can see links] ly+one+ryshu+and+there+is+only+one+techo+master
&submit=I+Know!!!+Let+Me+Solve+The+Puzzle!


When I copy and paste this exact same request into my browser, it finishes the game without a hitch. What is it about Python alone that is causing this submission to fail?

j03
02-04-2012, 11:53 AM
Based on the error I think you are missing a host in your wrapper (if you are using one). Is it possible to post some of your code for us to see what you are doing?

Neoquest
02-04-2012, 03:15 PM
Based on the error I think you are missing a host in your wrapper (if you are using one). Is it possible to post some of your code for us to see what you are doing?

I'm actually not using a wrapper. The only code before that is determining what saying is required to win the game.

Joshsadf
02-04-2012, 03:25 PM
Does it need a referrer in the request?

Neoquest
02-04-2012, 03:40 PM
Does it need a referrer in the request?

Nope, as I said before it could completed just fine in the browser. Unless I misunderstand what referrer means.

Miguel
02-04-2012, 05:49 PM
Referrer is an HTTP header that is sent when you send data through a browser, usually says what the page you came from is

Neoquest
02-04-2012, 06:12 PM
Yeah, that was my understanding of it. I don't really think that's the issue though, considering I can be on any page I want when sending the request from in a browser, and I'm on the correct page with the program.

Reemer
02-04-2012, 06:22 PM
Try a GET instead of POST. That happened to me one time

Neoquest
02-04-2012, 06:25 PM
Hm, this is really weird. When I use my Cliffhanger AP to generate the request and then execute it in a different program it goes off without a hitch.


Try a GET instead of POST. That happened to me one time

Didn't work. Why would that work though? The form asks for a POST.

Reemer
02-04-2012, 06:38 PM
For my Subeta autoquesters HTTP Live Headers and Tamper Data both said it was a POST, and after hours of frustration I changed it to a GET and it worked.

Neoquest
02-04-2012, 06:51 PM
For my Subeta autoquesters HTTP Live Headers and Tamper Data both said it was a POST, and after hours of frustration I changed it to a GET and it worked.

I think it actually has something to do with other code, not the actual request. As I mentioned earlier when I use the same request in a different program it works. So I have no idea.

Soredavide
02-05-2012, 06:43 AM
Post worked for my autoplayer, I am just using a modified Gluraks wrapper (VB6). I also did not try to enter the code usiing the submit
&submit=I+Know!!!+Let+Me+Solve+The+Puzzle!



strhtml = [Only registered and activated users can see links]("[Only registered and activated users can see links]", "solve_puzzle=" & txtAnswer.Text, "[Only registered and activated users can see links]")

Neoquest
02-05-2012, 12:55 PM
Post worked for my autoplayer, I am just using a modified Gluraks wrapper (VB6). I also did not try to enter the code usiing the submit
&submit=I+Know!!!+Let+Me+Solve+The+Puzzle!



strhtml = [Only registered and activated users can see links]("[Only registered and activated users can see links]", "solve_puzzle=" & txtAnswer.Text, "[Only registered and activated users can see links]")


Awesome, that worked! Thanks so much!