A webiste http://www.example.com have many lists in it. That is,
<ol>
<li>This is a list saying about asp</li>
<li>This is a list saying about javascript</li>
<li>This is a list saying about php</li>
<li>This is a list saying about .net</li>
</ol>
I need to Get the list with a word “php” using php.
That is the output should be “This is a list saying about php“
How can i do this with preg_match???
I used CURL class to fetch the HTML contents.
here is the code i used
$site = $curl->get("http://www.example.com/outputs.html");
$pattern = 'I NEED TO GET THIS PATTERN';
preg_match($pattern, $site, $matches);
$php_out = $matches[1];
echo $php_out;
when i use,
$pattern = '/<li>(.*?)<\/li>/s';
It returns the first result
That is “This is a list saying about asp“
You need a website crawler and a parser. There is a project called PHPCrawl with this lib you can crawl the site and get the content. Then you can parse and search in the source code for the specified pattern. If you want you can do it with a regex.
But i think you are not the first here on Stackoverflow with this problem. Perhaps you should search here and you’ll get some more information.