Re: using CURL to post data to a search engine
| From: | Chris Shiflett | Date: | Sat, 28 Sep 2002 03:25:25 +0000 |
| Subject: | Re: using CURL to post data to a search engine | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-117914@lists.php.net to get a copy of this message | ||
Google uses GET anyway, not POST.
A simple fopen() is all you need, but then you'll be parsing HTML. The API is better for reliability.
Paul Nicholson wrote:
I don't think you'll get php to work with google unless you use the google api - I heard that google has filtered out the php(and others) user-agent. If you need more info on the google api just let me know. On Friday 27 September 2002 07:25 pm, rdkurth@starband.net wrote:I am trying to use curl to post data to a search engine and then return the results in a variable so I can manipulate it. I have tried this but it does not seam to work properly. This is just an example of how I am trying to do this I don't have to use google for the search engine just thought if I can get it working with this I can get it to work with others $ch = curl_init ("http://www.google.com/"); curl_setopt ($ch, CURLOPT_POST, 1); $word="php"; $args="action=/search&hl=en&ie=UTF-8&oe=UTF-8&q=$word&btnG=Google Search"; curl_setopt ($ch, CURLOPT_POSTFIELDS, $args); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec ($ch); curl_close ($ch); echo $data;