php - How to find specific query in the URL and display whole link -
current code :
include 'simple_html_dom.php'; // create dom url or file $html = file_get_html('http://www.anylinkalsocan.com'); // find links foreach($html->find('a') $element) echo $element->href . '<br>';
it crawl , find tag :
<a href="http://news.example.com/node">
and output link found on website.
example
http://news.example.com.my/node/321072 http://news.example.com.my/taxonomy/term/2 http://news.example.com.my/node/321060?tid=2
i want search url contain ?tid=
can see on 3rd url in example.
http://news.example.com.my/node/321060?tid=2
i replace echo $element->href="*?tid
return error. can me this?
you can use preg_match or can check urls taken if contain ?tid
<?php include 'simple_html_dom.php'; // create dom url or file $html = file_get_html('http://www.anylinkalsocan.com'); // find links foreach($html->find('a') $element) { $search = '?tid'; if(strpos($element->href,$search)) { echo $element->href . '<br>'; } } ?>
Comments
Post a Comment