- Code: Select all
import urllib
import os
from HTMLParser import HTMLParser
class OliverClient(HTMLParser):
def __init__(self):
HTMLParser.__init__(self)
self.session_name = ""
self.botname = "Oliver"
self.i = 1
self.input1 = ""
self.input = "Stranger"
def handle_starttag(self, tag, attrs):
print tag
if tag == "input":
print "Doing this"
for name,value in attrs:
if name == "<?session_name()?>":
self.session_name = value
elif name == "botname":
self.botname = value
elif name == "i":
self.i = i
elif name == "input1":
self.input1 = input1
def printVals(self):
print "session: ", self.session_name
print "botname: ", self.botname
print "i: ", self.i
print "input1: ", self.input1
print "input: ", self.input
def makeRequest(self):
values = {"<?=session_name()?>": self.session_name, "botname": self.botname,
"i": self.i, "input1": self.input1, "input": self.input}
data = urllib.urlencode(values)
infile = urllib.urlopen("http://www.bored.com/oliverbot/php_chatter/src/talk.php", data)
s = infile.read()
self.feed(s)
oclient = OliverClient()
oclient.makeRequest()
The problem I'm encountering is that this doesn't go through all the tags on the page, and, thus, doesn't set the values as it should. Now, this isn't really a major set back. I'm just really confused as to why this is occurring. It goes through the first few dozen or so tags and then just stops.
- Code: Select all
html
head
meta
meta
meta
meta
title
link
link
link
link
script
script
script
script
script
body
div
div
div
div
h1
a
span
div
div
div
div
div
ul
li
I'm really confused. Anyone have any idea what may be causing this?

