Answer the question
In order to leave comments, you need to log in
Why is it not parsed?
You need to parse the text of the news - www.ferra.ru/ru/byt/news/2016/01/11/CES2016-Samsun...
I'm trying
this, it should work, but it doesn't work...
$page = file_get_contents("http://www.ferra.ru/ru/byt/news/2016/01/11/CES2016-Samsung-POWERbot-Turbo-Essential-Wi-Fi" . $val);
preg_match('#<div class="newsbody">([^<]+)</div>#', $page, $descr);
var_dump($descr);
Answer the question
In order to leave comments, you need to log in
However, I would prefer to parse this case via XML.
$html = <<<HTML
<div class="header">
<nyan-cats></nyan-cats>
</div>
<div class="content">
<div class="newsbody">
some random content
<span>HOT</span>
</div>
</div>
HTML;
$ok = preg_match('#<div class="newsbody">(.+?)</div>#s', $html, $descr);
var_dump($ok, $descr);
int(1)
array(2) {
[0]=>
string(86) "<div class="newsbody">
some random content
<span>HOT</span>
</div>"
[1]=>
string(58) "
some random content
<span>HOT</span>
"
}
Thanks It works.
Another question is how to parse from here? I also wrote a regular expression, but something does not work.
$page = file_get_contents("http://www.3dnews.ru/926439");
preg_match('#<div class="([^<]+)" itemprop="articleBody">([^<]+)</div>#', $page, $descr);
var_dump($descr);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question