D
D
danyfir2017-10-24 19:31:03
PHP
danyfir, 2017-10-24 19:31:03

How to create a parser?

I've been suffering for a long time, trying to compose a parser, but I'm stuck on regular expressions...
I'm trying to get a link to the background image of the VK group (let's say from the group https://vk.com/officialpages) in order to put it on the site and it was updated when the admin will update the background image in the group
.... it is in style, I want to get at least the entire block and remove the unnecessary part from there using substr, but if you tell me how to pull out the link directly, I will be grateful.
The parser itself produces an empty page:

$content = file_get_contents('https://vk.com/officialpages');
preg_match_all ('|<div class="page_block"><[^>]+>(.*)</[^>]+></div>|isU', $content, $content2, PREG_SET_ORDER);
echo $content2['0']['1'];

PS: sorry for the stupid question, maybe this is the first time I'm poking a parser...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2017-10-24
@dimonchik2013

DOM is generally better,
but you can start with a parse saved on disk

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question