Created
December 24, 2009 19:22
-
-
Save t-ashula/263318 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- ./tween0810.org/Tween/Twitter.vb 金 12 25 03:57:50 2009 | |
+++ ./tween0810/Tween/Twitter.vb 金 12 25 03:57:50 2009 | |
@@ -2152,35 +2152,34 @@ | |
Dim lineCount As Integer = 0 | |
Dim page As Long = -1 | |
+ Dim screenNameMatch As Regex = New Regex("<span class=""label screenname""><a href=""https://twitter.com/[^>]+>(?<scname>[^<]+)</a>", _ | |
+ RegexOptions.IgnoreCase Or RegexOptions.Compiled) | |
+ Dim paginationMatch As Regex = New Regex("<a href=""/followers\?page=(?<np>[0-9]+)"" class=""section_links"" rel=""me next""", _ | |
+ RegexOptions.IgnoreCase Or RegexOptions.Compiled) | |
Do | |
If _endingFlag Then Exit Do | |
- resMsg = DirectCast(CreateSocket.GetWebResponse("https://" + _hubServer + _GetFollowers + _cursorQry + page.ToString, resStatus, MySocket.REQ_TYPE.ReqGetAPI), String) | |
+ resMsg = DirectCast(CreateSocket.GetWebResponse("https://" + _hubServer + "/followers" + "?page=" + page.ToString, resStatus, MySocket.REQ_TYPE.ReqGetApp), String) | |
If resStatus.StartsWith("OK") = False Then | |
_threadErr = True | |
Return resStatus | |
End If | |
Try | |
- Using rd As Xml.XmlTextReader = New Xml.XmlTextReader(New System.IO.StringReader(resMsg)) | |
- lineCount = 0 | |
- rd.Read() | |
- While rd.EOF = False | |
- If rd.IsStartElement("screen_name") Then | |
- Dim tmp As String = rd.ReadElementString("screen_name").ToLower() | |
- SyncLock LockObj | |
- If Not tmpFollower.Contains(tmp) Then | |
- tmpFollower.Add(tmp) | |
- End If | |
- End SyncLock | |
- lineCount += 1 | |
- ElseIf rd.IsStartElement("next_cursor") Then | |
- page = Long.Parse(rd.ReadElementString("next_cursor")) | |
- If page = 0 Then Exit Do | |
- Exit While | |
- Else | |
- rd.Read() | |
+ lineCount = 0 | |
+ Dim scs As MatchCollection = screenNameMatch.Matches(resMsg) | |
+ For Each m As Match In scs | |
+ Dim tmp As String = m.Groups("scname").Value.ToLower() | |
+ SyncLock LockObj | |
+ If Not tmpFollower.Contains(tmp) Then | |
+ tmpFollower.Add(tmp) | |
+ 'Trace.WriteLine(page.ToString() + " : " + tmp) | |
End If | |
- End While | |
- End Using | |
+ End SyncLock | |
+ Next | |
+ Dim pgs As MatchCollection = paginationMatch.Matches(resMsg) | |
+ If pgs.Count <> 0 Then | |
+ page = System.Convert.ToInt64(pgs(0).Groups("np").Value) | |
+ lineCount = 1 | |
+ End If | |
Catch ex As Exception | |
_threadErr = True | |
TraceOut("NG(XmlException)") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment