D
D
doodoser2018-07-13 23:13:16
PHP
doodoser, 2018-07-13 23:13:16

Why does preg_match_all return an empty array?

Good evening, I'm trying to write a parser, I take the page through cURL (everything is fine, the page is completely taken away)
then I want to pull out all the links to the news using a regular expression, here's the code:

preg_match_all("/<div class=\"article\">.*href=\"(.*)\">/U", $html, $links);

I wrote the regex on the site https://regex101.com, the regex works there, but in the code it outputs an empty array.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
doodoser, 2018-07-14
@doodoser

that's all, I deduced, it was necessary to push an array into a variable that gives preg_match_all

P
Pavel Kornilov, 2018-07-14
@KorniloFF

Here is what you need, IMHO - https://github.com/Imangazaliev/DiDOM

D
Dimonchik, 2018-07-14
@dimonchik2013

href="([^"]+)"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question