Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

[cgi] Automating a POST form

Options
  • 26-03-2004 8:49pm
    #1
    Registered Users Posts: 1,865 ✭✭✭


    If there is a CGI script that uses a GET method then you can generate the URL by just sticking it onto the end of the URL. (Similar to what happens with boards.ie) So if one has a web page that has a CGI script to search, one can write a little programme that will take in a string and can print out the URL of what you'd get if you tried to search for that. You could then download the files using wget or something like that.

    That's all grand, but there is a search engine I use that uses the POST method. I'd like to be able to automate my searching by taking in a search string and downloading the webpage that it spits back, but how can I do this if it uses the POST method? If it uses GET it's not that hard. What about POST? Is it even possible?

    I've looked into CGI programming, and I can't seem to find a way to do it. All I know is that a POST CGI form will generate a little file that it sends as input to the CGI programme and that progamme will send back the webpage. So how can I 'send a little file to a CGI programme'?


Comments

  • Closed Accounts Posts: 7 dicey


    Originally posted by Syth

    What about POST? Is it even possible?

    I've looked into CGI programming, and I can't seem to find a way to do it. All I know is that a POST CGI form will generate a little file that it sends as input to the CGI programme and that progamme will send back the webpage. So how can I 'send a little file to a CGI programme'?

    Yes, it is possible - I can't remember exactly off the top of my head, but I think you just need to put the parameters into the body of the request instead of appending as you would with a GET. You can do this using libwww-perl if you don't mind using perl.


  • Registered Users Posts: 1,865 ✭✭✭Syth


    I've read up a bit more and I don't think I was that clear the first time round. What I don't know is how I can write to the standard input of a CGI script from they command line. Is there any programme that can do this, and then print out the result? How could I write the programme my self?


  • Closed Accounts Posts: 304 ✭✭Zaltais


    As dicey mentioned the libwww-perl (or LWP) module is very good at this.

    In actuality if you're
    writ[ing] to the standard input of a CGI script from they command line
    , you are actually POST'ing values to a [CGI] script over HTTP

    However, have you tried just passing the query to the page in the URL? Just because the requesting form uses a POST, doesn't necessarily mean that the resultant page will not understand a GET request.

    Post up a link to the site you're trying to query.


  • Registered Users Posts: 1,865 ✭✭✭Syth


    However, have you tried just passing the query to the page in the URL? Just because the requesting form uses a POST, doesn't necessarily mean that the resultant page will not understand a GET request
    Actually that works!! Cool! I used FireFox's Page Info thinge to get the values of all the form field info from a sample search, and it works. I didn't know you could do that. This is the site : http://amun.serveftp.com
    Sometimes the links don't work, so you have to check many of them. This is tedious and boring. I want to get a shell script to do it. Now I can. Thanks!


Advertisement