Hello everyone, help write a regular expression to get the code from the href-attribute
href="watch?v= тут код" from a huge string of html content.
Hello everyone, help write a regular expression to get the code from the href-attribute
href="watch?v= тут код" from a huge string of html content.
You can do the following:
<?php $html = 'href="watch?v= тут код"'; preg_match('/href="watch\?v=([^"]+)"/', $html, $out); echo $out[1]; + sign ? ? Thank. - Sasha Chernykhthat's what I'm doing:
$youtubeUri = "http://www.youtube.com/results?search_type=videos&search_query=".$filmsInfo[$key]['title']; $request = $this->client->request('GET', $youtubeUri); $content = $request->getBody()->getContents(); // Тут весь контент есть с ним всё хорошо. Usually I use symfony crawler
$crawler = new Crawler($content)->filter('#results')->html(); But in my cases with youtube, I don’t know why there is a block early-body in which iframe with some Doctype and crawler we only see its content, the other one doesn’t see
Source: https://ru.stackoverflow.com/questions/521670/
All Articles
/от(.*?)до/(/от(.*?)до/do/от(.*?)до/- Mike(?<=[href|src]=")https?:\/\/.*?(?="). Demonstration - Sasha Chernykh