Andreik Posted August 25, 2009 Share Posted August 25, 2009 (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. Edited August 25, 2009 by Andreik When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Szhlopp Posted August 25, 2009 Share Posted August 25, 2009 (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 August 25, 2009 by Szhlopp RegEx/RegExRep Tester!Nerd Olympics - Community App!Login UDFMemory UDF - "Game.exe+753EC" - CE pointer to AU3Password Manager W/ SourceDataFiler - Include files in your au3!--- Was I helpful? Click the little green '+' Link to comment Share on other sites More sharing options...
Andreik Posted August 26, 2009 Author Share Posted August 26, 2009 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. Link to comment Share on other sites More sharing options...
Szhlopp Posted August 26, 2009 Share Posted August 26, 2009 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 RegEx/RegExRep Tester!Nerd Olympics - Community App!Login UDFMemory UDF - "Game.exe+753EC" - CE pointer to AU3Password Manager W/ SourceDataFiler - Include files in your au3!--- Was I helpful? Click the little green '+' Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now