I need a simple regex program that will allow me to paste in youtube video urls and it regex the amount of video views each video has. If anyone wants to do this I can pay them
I might be wrong but I think this should be in the Hire a Freelancer section. Anyway, I would be happy to do it for you - add me on skype: ryanleelambert edit: My Bad, I misread the date on this one.
Here is something simple for you (put it on notepad and save as get_views_count.php or any other name u wish): Code: <?php $videos = $_POST['videos']; $userAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0'; $url = 'http://www.youtube.com/watch?v='; ?> <form action="<?=$_SERVER['PHP_SELF']?>" method="post"> List of videos (1 per line):<br /> <textarea name="videos" cols="60" rows="10"></textarea><br /> <input type="submit" value="Get Views"><br /> </form> <br /><br /> <? if (!isset($videos)) { echo "Fill in the above form with a list of videos. <br />\n"; exit; } echo "Results: <br />\n"; foreach(explode("\n", $videos) as $video) { parse_str(parse_url($video, PHP_URL_QUERY), $url_vars); echo "Video: " . $url . $url_vars['v'] . "<br />\n"; $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent ); curl_setopt($ch, CURLOPT_URL,$url . $url_vars['v']); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $html = curl_exec($ch); if(curl_errno($ch)) { echo "Error: " . curl_error($ch) . "<br />\n"; } curl_close($ch); $doc = new DOMDocument(); @$doc->loadHTML($html); $xpath = new DOMXpath($doc); $node = $xpath->query('//span[@class="watch-view-count"]/text()')->item(0); echo "Views: " . $node->textContent . "<br />\n"; echo "-------------------------------------------------------------<br />\n"; } Its made in php so you place it on your hosting and access it like http://yoursite.com/get_views_count.php and you will see a box to put in the videos URL. It will extract the video ID automatically and return the URL of the video with its views count below it.
here is the regex to get youtube view (?<=\<div\ class\=\"watch\-view\-count\"\>).*?(?=\ views\<\/div\>)