Results 1 to 2 of 2

Thread: Fetching data from webpage based on elements ID/Class

  1. #1
    Join Date
    Mar 2011
    Posts
    4

    Fetching data from webpage based on elements ID/Class

    Hi, I'm searching for a way or an existing API/function that does the following:

    I want to give this function a URL and an ID/Class,
    the function will return an array of the HTML/Text content of
    the HTML elements that possess these attributes.

    Where do I even start with this thing?

  2. #2
    Join Date
    Apr 2009
    Location
    The toon
    Posts
    1,225
    look at cURL in PHP

    example...

    PHP Code:
    $url "www.mysite.com"// change to suit
    $ch curl_init($url);
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
    $html curl_exec($ch);
    curl_close($ch);
    echo 
    $html// $html contains the page, in HTML, which you have scraped 
    You will need to process the $html variable to fish out what you want and output it to the page.

Similar Threads

  1. Pre-select form elements based on history
    By jjspelman in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 03 Apr 2011, 10:05 AM
  2. Loading different html files on my server into webpage based on clicked links
    By kaijunexus in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 18 Feb 2011, 01:29 PM
  3. Javascript: Make elements appear based on user interaction
    By mrtylersmith in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 18 Jul 2009, 04:40 PM
  4. Replies: 0
    Last Post: 14 Apr 2009, 12:10 PM

Posting Permissions

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