A
A
Alexander Tokmakov2018-06-20 04:03:22
PHP
Alexander Tokmakov, 2018-06-20 04:03:22

How to parse content correctly?

There is a page:

<html>
<body>
<div class="content__right content__right_cols_12" data-log-node="4r91">
<div class="serp-list">
<div class="serp-adv__found">Нашлось 88 результатов</div>
</div>
</div>
</dody>
</html>

Help me write a string parser in php: Found 88 results
My variant is not suitable:
preg_match('#]+?class\s*?=\s*?"serp-adv__found"[^>]*?>(.+?)# su', $str, $arr);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2018-06-20
@calliko

this is done by DOM parsers,
for example
https://github.com/paquettg/php-html-parser
or by all sorts of nokogiri
if so, the regexp will be
class="[^"]+">([^<]+)<

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question