CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1

Thread: How To Auto Type In Search Box And Click Search Button ?

  1. #1
    Join Date
    Aug 2017
    Posts
    17

    How To Auto Type In Search Box And Click Search Button ?

    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 ****.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:

    Code:
    $keywords = blah blah;
    $url = "http://www.****.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);
    echo "$result";
    So, with my cURL, I have managed to load ****.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.
    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.
    Last edited by coding_student; September 25th, 2017 at 07:16 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)