Sign in to follow this  
Followers 0
Andreik

Facebook bar

4 posts in this topic

#1 ·  Posted (edited)

Those who use facebook know that exists a bar like a quick launch for photos, videos,notes, links, etc. On this bar is also the number of online firends. Know anyone how can I read this number from the bar? Can I read with IE functions?

I attach a photo for those who didn't know about what I talk.

Posted Image

Edited by Andreik

When the words fail... music speaks

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Here ya go man. I would put it in a function if I knew how you were going to use it... But this works.

$Friends[0][0] = Count

$Friends[n][0] = Name

$Friends[n][1] = Status

Don't know how this reacts when nobody is on, or how it reacts if you're offline. I just made it work >_<

#include <IE.au3>
#include <Array.au3>
;
Global $Friends[1][2]


; Attach/Read
$oIE = _IEAttach("facebook.com", "URL")
$Text = _IEBodyReadHTML($oIE)

; Set count
$Count = StringRegExp($Text, 'count\_num\>\(<STRONG>(.*?)\<', 1)
$Friends[0][0] = $Count[0]
If $Count >=1 Then
    ; Get Name/Status
    $OnlineFriends = StringRegExp($Text, 'buddy\_list\_item\_name\_(\d*?)\>(.*?)\<', 3)
    For $I = 0 To UBound($OnlineFriends) - 1 Step 2

        $Name = $OnlineFriends[$I + 1]
        $ID = $OnlineFriends[$I]

        ; Redim/Set Name
        ReDim $Friends[UBound($Friends) + 1][2]
        $Friends[UBound($Friends) - 1][0] = $Name

        ;Get Status
        $Status = StringRegExp($Text, $ID & '\s(?:.*?)\<A\sclass\=clearfix\stitle\=\"(.*?)onclick', 1)
        If Not @error Then
            $Friends[UBound($Friends) - 1][1] = StringTrimRight($Status[0], 2)
        EndIf
    Next
EndIf


_ArrayDisplay($Friends)

GL

EDIT: Only gets names if 1 or more is on. Also fixed the status updates

Szh

Edited by Szhlopp

Share this post


Link to post
Share on other sites

Thanks Szhlopp.

I will use this to play a sound for each friend that log in and another sound for each one who go offline.


When the words fail... music speaks

Share this post


Link to post
Share on other sites

Thanks Szhlopp.

I will use this to play a sound for each friend that log in and another sound for each one who go offline.

=)

You use FF eh? Convert the script to use the firefox methods of what I do here. All it does it grab the HTML off of the page and use SRE to get the info I need.

Here is the script, one more time with the error checking on the '$count'

#include <IE.au3>
#include <Array.au3>
;
Global $Friends[1][2]


; Attach/Read
$oIE = _IEAttach("facebook.com", "URL")
$Text = _IEBodyReadHTML($oIE)

; Set count
$Count = StringRegExp($Text, 'count\_num\>\(<STRONG>(.*?)\<', 1)
If Not @error Then $Friends[0][0] = $Count[0]

If $Friends[0][0] >=1 Then
    ; Get Name/Status
    $OnlineFriends = StringRegExp($Text, 'buddy\_list\_item\_name\_(\d*?)\>(.*?)\<', 3)
    For $I = 0 To UBound($OnlineFriends) - 1 Step 2

        $Name = $OnlineFriends[$I + 1]
        $ID = $OnlineFriends[$I]

        ; Redim/Set Name
        ReDim $Friends[UBound($Friends) + 1][2]
        $Friends[UBound($Friends) - 1][0] = $Name

        ;Get Status
        $Status = StringRegExp($Text, $ID & '\s(?:.*?)\<A\sclass\=clearfix\stitle\=\"(.*?)onclick', 1)
        If Not @error Then
            $Friends[UBound($Friends) - 1][1] = StringTrimRight($Status[0], 2)
        EndIf
    Next
EndIf


_ArrayDisplay($Friends)

If you still can't make it work with FireFox, send me a PM with whatever the '_FFGetHTML command' returns. I'll make sure my SRE patterns are returning right.

Szh

Share this post


Link to post
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
Sign in to follow this  
Followers 0