1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

simple regex program

Discussion in 'Hire a Freelancer' started by threeman, Feb 14, 2012.

  1. threeman

    threeman Newbie

    Joined:
    Apr 28, 2010
    Messages:
    23
    Likes Received:
    0
    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
     
  2. CodeKing

    CodeKing Newbie

    Joined:
    Feb 18, 2013
    Messages:
    21
    Likes Received:
    5
    Occupation:
    Freelance software developer
    Location:
    Shizuoka-shi, Japan
    Home Page:
    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.
     
  3. jazzc

    jazzc Moderator Staff Member Moderator Jr. VIP

    Joined:
    Jan 27, 2009
    Messages:
    2,468
    Likes Received:
    10,155
    Moved to the HAF section :)
     
  4. Jesse Pinkman

    Jesse Pinkman Newbie

    Joined:
    Feb 18, 2013
    Messages:
    12
    Likes Received:
    0
    Add my friend on skype: biteoo.glp
    He might help you
     
  5. cgimaster

    cgimaster Power Member

    Joined:
    Jun 30, 2012
    Messages:
    525
    Likes Received:
    311
    Gender:
    Male
    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.
     
    Last edited: Feb 19, 2013
  6. magicaltoaster

    magicaltoaster Newbie

    Joined:
    Feb 20, 2013
    Messages:
    14
    Likes Received:
    0
    You can do this with a porn video ripper (lol)