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.
$data = file_get_contents($url);
preg_match( "|$start_tag(.*)$end_tag|s", $data, $match);
return match[1];
}
$start_tag = '
';
$end_tag = '
$url = 'https://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.
Hi,
small sytax change in the code. One is $match[1] on return. And parameter was missing. when supplied.
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 = '
';
';$end_tag = '
$url = 'https://tildemark.com/';
$tag_contents = get_tag_contents($start_tag, $end_tag,$url);
print $tag_contents;