urllib2 - not returning page expected after post

D

David Feyo

I'm trying to automate reverse-ip lookups on domaintools.com.
Everything is fine, except that I don't exactly get the data I want
after I submit a post to the site. I know the post is correct, the
return data just doesn't appear on the post. Not sure what to do at
this point. Here is the code:

#!/usr/bin/env python
import urllib2, urllib, httplib, cookielib

h=urllib2.HTTPHandler(debuglevel=1)
cj = cookielib.MozillaCookieJar()

##Add some data to the url
data = urllib.urlencode({'hostname': 'google.com'})

##Add a cookie handler
cookieHandler = urllib2.HTTPCookieProcessor(cj)
redirectionHandler = urllib2.HTTPRedirectHandler()

##Creating a request object - takes url of resource I want to retrieve
request = urllib2.Request('http://www.domaintools.com/research/reverse-
ip/', data)

##adding useragent to request object
request.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT
6.1; en-US; rv:1.9.2.15) Gecko/20110303 Firefox/3.6.15')

##Creating a url opener; can take an number of handlers, which control
how responses are handled
opener = urllib2.build_opener(h, cookieHandler, redirectionHandler)

##tell the opener to open the url
response = opener.open(request)
text = response.read()
print text
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top