Timed 6
This one seems easy enough. dictionary to get the 'seventh' = 7 part. simple parsing for the number.
I'm just having a hard time with the RE to grab a line of html. I don't wanna spoil, but the html is <a href="[URL]" class=l onmousedown="return clk(this.href,'','','res','[nth result]','')"> My RE is HIDEOUS. having " and ' and needing python escapes as weel as re escape makes it worse. Anyone have a relatively simple RE for this?
a good way to do this is the HTMLParser class in python.
And theres a good article and code bank bit for this particular challenge.
read
http://www.hellboundhackers.org/articles/841-using-python-39;s-htmlparser-class.html
http://www.hellboundhackers.org/code/readcode.php?id=1145
as for the capturing of the item needed you could do something like this
google_term=re.findall('<strong>[a-z\s\w]+</strong>', source)[-2]
Yes, i have it all.
I use the HTMLParser to find all class=l a href links, then i grab the nth. I base64.encode() it, then throw it in as an argument, but it does work. I then tried adding some extra info, but i kept that info blank, hoping it would change the method to POST, but it's either not changing it to POST or it's still not working.
The_Gman wrote: You're right, I don't know what language I'm programming in. :right:
from HTMLParser import HTMLParser
import base64
...
b64url = base64.b64encode(url)
...
result = opener.open("http://www.hellboundhackers.org/challenges/timed/timed6/index.php?url=%s" % b64url, blankdata)
You are using a GET request. Try reading this: http://mail.python.org/pipermail/python-list/2004-June/268493.html
stdio wrote: [quote]The_Gman wrote: You're right, I don't know what language I'm programming in. :right:
from HTMLParser import HTMLParser
import base64
...
b64url = base64.b64encode(url)
...
result = opener.open("http://www.hellboundhackers.org/challenges/timed/timed6/index.php?url=%s" % b64url, blankdata)
You are using a GET request. Try reading this: http://mail.python.org/pipermail/python-list/2004-June/268493.html[/quote]
But I'm including some url encoded data, the manual said it should work as post.
should i even url encode the url=? part?
Thanks
The_Gman wrote: You're right, I don't know what language I'm programming in. :right:
from HTMLParser import HTMLParser
import base64
...
b64url = base64.b64encode(url)
...
result = opener.open("http://www.hellboundhackers.org/challenges/timed/timed6/index.php?url=%s" % b64url, blankdata)
Alright sorry man…. try using urllib2's Request class.
I made it so it posts. This is the header
POST /challenges/timed/timed6/index.php HTTP/1.1 Accept-Encoding: identity Content-Length: 52 Connection: close User-Agent: Python-urllib/2.5 Host: www.hellboundhackers.org Cookie:cookiestuff Referer: http://www.hellboundhackers.org/index.php Content-Type: application/x-www-form-urlencoded url=aHR0cDovL3d3dy5tb3ppbGxhLm9yZy9kb3dubG9hZC5odG1s
The word i got was firefox 4th entry http://www.mozilla.org/download.html
Does that look right?
Thanks,