View Single Post
Old 05-10-2012, 02:12 PM   PM User | #2
bjarneo
New Coder

 
Join Date: May 2012
Posts: 50
Thanks: 6
Thanked 4 Times in 4 Posts
bjarneo is an unknown quantity at this point
I don't know any program. But maybe you can tweak this regex / code to fetch whatever you want from the site DOM.

This code fetch all links from codingforums.com php thread.
file_get_contents() php.net: http://no.php.net/manual/en/function...t-contents.php

PHP Code:
<?php

$html 
file_get_contents('http://www.codingforums.com/forumdisplay.php?f=6');
$links pc_link_extractor($html);
foreach(
$links as $link)
{
    print 
$link[0] . "<br />\r\n";
}

function 
pc_link_extractor($html)
{
    
$links = array();
    
preg_match_all('/<a\s+.*?href=[\"\']?([^\"\' >]*)[\"\']?[^>]*>(.*?)<\/a>/i'$html$matchesPREG_SET_ORDER);
    foreach(
$matches as $match)
    {
        
$links[] = array($match[1], $match[2]);
    }
    return 
$links;
}


?>
If you want to grab the content with an interval in hours, use cronjobs. (If this is available).


Edit: cURL is also an option.

Last edit: http://php.net/manual/en/book.dom.php and http://www.php.net/manual/en/domdocu...lementbyid.php

Last edited by bjarneo; 05-10-2012 at 02:30 PM.. Reason: dom document.
bjarneo is offline   Reply With Quote