[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: Truoble With A Search Script for ImageBin.org

Steve Holden

3/19/2010 2:44:00 AM

Brandon Conner wrote:
> Hey Pythoners,
>
> its my first post here, yay!
>
> I'm trying to develop a script that will return the results of a POST
> request that should list all images uploaded by a user. However, when i
> run the script, i get returned the HTML of the page with the search
> form. I am wondering what am i doing incorrectly? Is it something I'm
> doing or is the imagebin server rejecting my request?
>
> here's the code:
>
> import urllib
> import urllib2
> url = 'http://imagebin.org/index.php?page=s...
> values = {'search_for' : 'blah', 'field' : 'Nickname'}
> data = urllib.urlencode(values)
> request = urllib2.Request(url, data)
> response = urllib2.urlopen(request)
> page = response.read()
> print page
>
> tks, pythons great
>
You need to tell the browser (in an HTTP header) that what you are
sending is HTML. Try putting

print "Content-Type: text/html\n"

at the start of your script.

regards
Steve

--
Steve Holden +1 571 484 6266 +1 800 494 3119
See PyCon Talks from Atlanta 2010 http://pyco...
Holden Web LLC http://www.hold...
UPCOMING EVENTS: http://holdenweb.event...