Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 8th, 2005, 7:56 PM   #1
uman
Expert Programmer
 
Join Date: Dec 2004
Posts: 794
Rep Power: 4 uman is on a distinguished road
I know there is a way for a script to query a web site through POST i.e. to fill out a form. What language should I use to do this and how hard is it to write?
__________________
Few people deserve to be compared to (Rush) Limbaugh, most of them were convicted at the Nuremburg trials.
--WilliamSChips on Slashdot
uman is offline   Reply With Quote
Old Jan 9th, 2005, 1:00 AM   #2
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
Actually I have successfully done this with Perl, PHP, and C++ (using MSIEX controls). You can simulate page form completions via POST and GET, of course GET is a little bit easier to do.

If you are using PHP, which is probably the easiest to use here, you have three ways of accomplishing your desired task...

1) Use the CURL libraries, send a CURL request and set the data transmmission to HTTP POST.

$c = curl_init( 'http://www.example.com/submit.php' );
curl_setopt( $c, CURLOPT_POST, 1 );
curl_setopt( $c, CURLOPT_POSTFIELDS, 'monkey=uncle&rhino=aunt' );
curl_setopt( $c, CURLOPT_RETURNTRANSFER, 1 ); //return the resulting HTML
$page = curl_exec( $c );
curl_close( $c );

2) You can download and use the PEAR HTTP_Request class to accomplish the same thing, in a slightly more object oriented manner.

$r = new HTTP_Request( 'http://www.example.com/submit.php' );
$r->setMethod( HTTP_REQUEST_METHOD_POST );
$r->addPostData( 'monkey', 'uncle' );
$r->addPostData( 'rhino', 'aunt' );
$r->sendRequest( );
$page = $r->getResponseBody( );
unset( $r );

3) Making a raw socket connection with the HTTP server and posting custom formatted headers which equate to the POST string you want to set along, this is stupidly complex if you have access to one of the above classes and I would recommend not bothering with it, since it tends not to be a very robust solution.

Good luck.
__________________
Clifford Matthew Roche <geek@cliffordroche.com>
Web Hosting: http://www.crd-hosting.com
Consulting: http://www.crdev-consulting.com
kurifu is offline   Reply With Quote
Old Jan 9th, 2005, 3:41 PM   #3
uman
Expert Programmer
 
Join Date: Dec 2004
Posts: 794
Rep Power: 4 uman is on a distinguished road
Thank you for the invaluable help! I don't know PHP at the moment. But this is important enough to me that I will learn it.

Thanks!
__________________
Few people deserve to be compared to (Rush) Limbaugh, most of them were convicted at the Nuremburg trials.
--WilliamSChips on Slashdot
uman is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:03 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC