cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: newbie--problem with POST

From: Jeff Alperin <jalperin_at_yahoo.com>
Date: Thu, 31 Oct 2002 15:28:55 -0800 (PST)

Hmm. Getting the same result, and it doesn't look like there are any cookies being set. I put the -v (verbose) option on and found the following in the output:
> POST /center/search/index/ HTTP/1.1
The page not found message says "The requested URL /center/search/index/ was not found on this server."
Has the first part of the url (i.e. https://center.atomz.com) gotten cut-off somehow? Maybe that's why it can't find the page?
--Jeff
 Ralph Mitchell <rmitchell_at_eds.com> wrote:One thing you're not doing is posting back to the page everything it expects to see. In my experience, web servers are often like little kids - you don't give them what they expect, they pout... :)
So, to keep the peace, try something more like this:
    curl -d "index=Index%20Now" -d "sp-cache=1" -d "sp-count=1" -o "ja_curl.html" -u "myusername:mypassword" "https://center.atomz.com/center/search/index/?sp-id=0011da71-sp10024a7&sp-efn=full&sp-fn=index"
OK, so maybe the data in the form action could also be passed using:
    -d "sp-id=0011da71-sp10024a7" -d "sp-efn=full" -d "sp-fn=index"
in which case you should leave the trailing '?' off the url. I'm not exactly sure if that would hand the server something different to what it expects, so you might want to try it both ways.
Lastly, when it works via the browser, do you go through any other pages? If so, your curl script could be missing out on a cookie collection. Again, in my experience, you need to start from the first page you get with the browser and collect cookies all along the way (and following redirects, but that's a whole 'nother sackful of ferrets... :).
Ralph Mitchell
  
Jeff Alperin wrote: I'm trying to automate the submission of a form and having problems. Here's how the process works with a browser: Log into site with username and password. Once logged in, click link to select appropriate page. Click Submit button on form.
The html for the form looks something like this:
<form action="?sp-id=0011da71-sp10024a7&sp-efn=full&sp-fn=index" method=POST>
<table width="100%" cellpadding=2 cellspacing=0 border=0>
<tr>
<td align=left valign=middle width="30%"><input type=Submit name=index value="Index Now"></td>
<td valign=middle width="30%"><input name="sp-cache" type=checkbox value=1><span class=blacktext>Clear index cache</span></td>
<td valign=middle width="30%"><input name="sp-count" type=checkbox value=1><span class=blacktext>Count all pages</span></td>
</tr>
</table>
</form>
When I use a browser the url for the page looks like this:
https://center.atomz.com/center/search/index/?sp-efn=full&sp-id=0011da71-sp10024a7
So, this is the curl command I used:
curl -d "sp-id=0011da71-sp10024a7&sp-efn=full" -o "ja_curl.html" -u "myusername:mypassword" "https://center.atomz.com/center/search/index/?"
The problem is that the resulting page is always "Page not found: The requested URL /center/search/index/ was not found on this server."
Interestingly, if I leave the -u "myusername:mypassword" off, it does pull a page from the server, but it's a page requesting me to log in.
Any ideas what I'm doing wrong? Thanks.
--Jeff
  

---------------------------------
Do you Yahoo!?
HotJobs - Search new jobs daily now

---------------------------------
Do you Yahoo!?
HotJobs - Search new jobs daily now

-------------------------------------------------------
This sf.net email is sponsored by: Influence the future
of Java(TM) technology. Join the Java Community
Process(SM) (JCP(SM)) program now.
http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0004en
Received on 2002-11-01