Here's a handy function to get specific tag contents. You could modify the tag you wish to scrape by changing the $start_tag and $end_tag variables. Useful in getting data from multiple html tags.
<?php
function get_tag_contents($start_tag, $end_tag, $url){
$data = file_get_contents($url);
preg_match( "|$start_tag(.*)$end_tag|s", $data, $match);
return match[1];
}
$start_tag = '<p>';
$end_tag = '</p>';
$url = 'http://www.tildemark.com/';
$tag_contents = get_tag_contents($start_tag, $end_tag);
print $tag_contents;
?>
function get_tag_contents($start_tag, $end_tag, $url){
$data = file_get_contents($url);
preg_match( "|$start_tag(.*)$end_tag|s", $data, $match);
return match[1];
}
$start_tag = '<p>';
$end_tag = '</p>';
$url = 'http://www.tildemark.com/';
$tag_contents = get_tag_contents($start_tag, $end_tag);
print $tag_contents;
?>
Fell free to modify this code and don't forget to post your changes here.
Leave a comment