I want to build a cURL script that auto searches a keyword on any site's search feature.
In this example, imagine I want it to search ebay.com.
How should I code it ?
What is the code that:
1. Types a keyword in the search box;
2. Clicks the search button.
I need the appropriate function names to research on them.
I am stuck at this point:
Expand|Select|Wrap|Line Numbers
- $keywords = blah blah;
- $url = "http://www.ebay.com";
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "$url");
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
- curl_setopt($ch, CURLOPT_HEADER, 5);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
- $result = curl_exec($ch);
- curl_close($ch);
Now, I need to tell the cURL to:
A). Find the item (search box) that has the following name attribute or id attribute and type the $keywords value onto it.
name="_nkw";
id="gh-ac";
B). Find the item (search button) that has the following name attribute or id attribute attribute and click it.
id="gh-btn";
value="Search";
I would appreciate any code snippet additions to it by anyone.
I am not that much learned to deal with API. Therefore, need the basic code lines that tell cURL or php how to identify items and type in them or click them. General code.
Thank you very much for your help.