Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.python
Re: Truoble With A Search Script for ImageBin.org
Cameron Simpson
3/19/2010 2:57:00 AM
On 18Mar2010 22:43, Steve Holden <steve@holdenweb.com> wrote:
| Brandon Conner wrote:
| > 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.
I think it may need to be "application/x-www-form-urlencoded", not
text/html. But otherwise, yes, missing Content-Type.
And the request method needs to be POST; I expect the code above will be
using GET unless told not to.
Cheers,
--
Cameron Simpson <cs@zip.com.au> DoD#743
http://www.cskk.ezoshosti...
There's no trick to being a humorist when you have the whole government
working for you. - Will Rogers
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: Truoble With A Search Script for ImageBin.org
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password