I need to crawl through a page and get the contents of a particular div. I have php and javascript as my two main options. How can it be done?
Answer
This is quite a basic method to do it PHP and it returns the content in plain text. However you might consider revising the regex for your particular need.
$link = file_get_contents("http://www.domain.com");
$file = strip_tags($link, "");
preg_match_all("/(?:[^<]*)<\/div>/is", $file, $content);
print_r($content);
?>
No comments:
Post a Comment