I want to get the title of an article from this page using regex and simplehtmldom : http://laperuanavegana.wordpress.com/about/
in this case title is : Cómo preparar SEITÁN
Here is my regex :
$html = file_get_html($url);
preg_match_all("title=(.*?)",$html->innertext,$title);
echo "this is title ".$title[0开发者_如何学编程][0]."<br>";
It would be helpful if anyone help me to find the bug.
I think you need to look for text between <title>
and </title>
, not for text following title=
.
For example:
$html = "Sometext<title>Seitan</title>More text";
preg_match_all('|<title>(.*?)</title>|',$html,$title);
echo "this is title ".$title[1][0]."<br>";
精彩评论