Jump to content

Possible to get view count on a youtube video?


Gui
 Share

Recommended Posts

Aye guys, i've tried like everything..(I think). I'm trying to get the view count of a video on youtube. This is the section of the source off the page.

<div id="watch-views-div">
                <span id="watch-views"><span id="watch-view-count">308</span> views</span>  <-- VIEWS ARE THERE.

                <a class="yt-tooltip" href="#"><img style="vertical-align: middle;" src="http://s.ytimg.com/yt/img/icn_help_question-vfl32654.gif"><span class="yt-tip"> Wondering about your view count? For popular videos, the counts are updated every few hours; if you're still getting views, you should see them soon.</span></a>

        </div>

This is what i've tried in AutoIt so far. There are 3 id's you see, and I didn't know which one was actually the '308', so I tested them all. All returned as 0.

$oForm = _IEFormGetCollection($oIE,0)
        sleep(2000)
        $x = _IEGetObjById($oForm,"watch-views-div")
        $a = _IEGetObjById($oForm,"watch-views")
        $l =  _IEGetObjById($oForm,"watch-view-count")
        msgbox(0,"",$x & $a & $l)
        $f = _IEFormElementGetValue($x) ; it equaled 0.
        $q = _IEFormElementGetValue($a) ; equaled 0..
        $g = _IEFormElementGetValue($l) ; same for this guy. -.-         
        msgbox(0,"",$f & $q & $g)

So is it the wrong id? Or am I just using the wrong funtions in _IE? Help on this would be greatly appreciated :). Sorry about all my other posts on issues, i'm a nub.

Thanks.

GUI.

Link to comment
Share on other sites

This is probably close but it's untested because the system I'm on right now doesn't have AutoIt installed.

$l =  _IEGetObjById($oForm,"watch-view-count")
$iCount = IEPropertyGet($l, "innertext")
MsgBox(0, "Result", $iCount)

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

This is probably close but it's untested because the system I'm on right now doesn't have AutoIt installed.

$l =  _IEGetObjById($oForm,"watch-view-count")
$iCount = IEPropertyGet($l, "innertext")
MsgBox(0, "Result", $iCount)

OIMFGFgfGADFJAOd~!!!@!#! It worked!! Thanks a bunch dude! I'm gonna remember that function forever woot! Thanks! :)!
Link to comment
Share on other sites

  • 4 years later...
  • Moderators

HankHill, perhaps you noticed this thread is over 5 YEARS old? Please don't necro old posts; the language has grown a lot since 2009, what worked then may not work today. Better to start a new thread, explain in detail what you're trying to do, and provide what you have already tried on your own (e.g. post script).

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...