Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Code cURL PHP Script to Auto Type In Search Box & Click Search Button?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.08k
    Answer it

    Hi,

    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:

     

    $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);


    So, with my cURL, I have managed to load ebay.com homepage.

    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.

    Thank you very much for your help.

 0 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: