Dim objIE0,sIe dim xml,doc,BaseURL Set doc = CreateObject("Microsoft.XMLDOM") Dim s,u(4000),nn(4000),e(99) Set Fs = WScript.CreateObject("Scripting.FileSystemObject") Set rankHtm = Fs.OpenTextFile("twittCeleb.htm",1) Set objIEx = CreateObject("InternetExplorer.application") objIEx.Navigate "about:blank" Do While objIEx.Busy
'Set xml = CreateObject("MSXML2.XMLHTTP") Set xml = CreateObject("WinHttp.WinHttpRequest.5.1") tUsername = "" 'Range("tusername") tPassword = "" 'Range("tpasswd") endd=false
Do WScript.Sleep 100 if objIEx.Document.all.start.checked=true then exit do if objIEx.Document.all.end.checked=true then endd=true exit do end if Loop if endd=true then exit do objIEx.Document.all.start.checked=false qq=objIEx.Document.all.q.value objIEx.Document.Write "search key=" & qq & "<br>"
q_utf8="" for i= 1 to len(qq) zz=SJIStoUTF8(mid(qq,i)) 'if i>1 then ' zz=right(zz,len(zz)-1) 'end if q_utf8=q_utf8 & zz next objIEx.Document.Write "utf8 key=" & q_utf8 & "<br>" xml.Open "POST", "http://search.twitter.com/search.json?q=" & q_utf8, "false", tUsername, tPassword xml.setRequestHeader "Content-Type", "content=text/html; charset=unicode" 'shift-jis" xml.send tResult = xml.responsetext 'you can view Twitter’s response in debug window Set oTs2 = Fs.OpenTextFile("q\" & qq & ".txt",2,true) oTs2.writeline xml.responsetext oTs2.close moto=xml.responseText do id=strmid(moto,"""id"":",",") if id="" then exit do objIEx.Document.Write "id=" & id & ":" xml.Open "POST", "http://api.twitter.com/1/friendships/create/" & id & ".xml", "false", tUsername, tPassword xml.setRequestHeader "Content-Type", "content=text/html; charset=unicode" 'shift-jis" xml.send tResult = xml.responsetext 'you can view Twitter’s response in debug window doc.loadXML (xml.responseText) If instr(doc.documentElement.selectSingleNode("error").nodeTypedValue,"not")>0 Then msg = doc.documentElement.selectSingleNode("error").nodeTypedValue objIEx.Document.write "エラー:" + "[" + msg + "]" else objIEx.Document.write "created" end if objIEx.Document.write "<br>" loop doc.loadXML (xml.responseText) ' objIEx.Document.Write doc.documentElement.selectSingleNode("error").nodeTypedValue 'if instr(doc.documentElement.selectSingleNode("error").nodeTypedValue,"not")>0 then ' exit for 'end if
' objIEx.Document.Write "<br>" loop objIEx.Document.Write "done" Set xml = Nothing Function strmid(org,mae,usiro) pos = InStr(org, mae) If pos > 0 Then strmid = Right(org, Len(org) - pos - Len(mae) + 1) org = strmid pos = InStr(strmid, usiro) If usiro = "" Then ' strmid = "" Else If pos > 0 Then strmid = Left(strmid, pos - 1) End If End If Else strmid = "" End If End Function Function SJIStoUTF8(strSJIS)
End Function 'HEX16進文字列を受け取り2進数文字列を返す Function HEX16toSTR2(strHEX)
Dim n 'ループカウンタ Dim i 'ループのカウンタ Dim n8421 '8 4 2 1の数値計算用 Dim str2STR
Dim nCHK
str2STR = "" '結果のエリアを初期化する
'文字数分ループする For n = 1 To Len(strHEX) On Error Resume Next 'エラー発生時次の行へ nCHK = 0 '0で初期化 nCHK = CInt("&h" & Mid(strHEX, n, 1)) 'n文字目を数値変換 On Error Goto 0 'エラー処理を通常に戻す
n8421 = 8 '初期値に8を代入する(上からチェックしたいので) For i = 1 To 4 '4回まわるよ If (nCHK And n8421) = 0 Then 'Andでビットをチェックする str2STR = str2STR & "0" 'ビットは立ってないよ Else str2STR = str2STR & "1" 'ビットは立ってるよ End If '次のビットをチェックしたいので2で割る n8421 = n8421 / 2 Next Next
'リターン値をセットして終了 HEX16toSTR2 = str2STR
End Function
'2進文字列を受け取り16進文字列を返す Function STR2toHEX16(str2)
Dim strHEX Dim n 'ループカウンタ Dim i 'ループのカウンタ Dim n8421 '8 4 2 1の数値計算用 Dim nBYTE
'頭4文字単位かチェックする n = Len(str2) Mod 4 '足りない文字数を計算する If n <> 0 Then str2 = String(4 - n, "0") & str2 '頭に文字0を追加する End If
strHEX = "" '結果のエリアを初期化する
'文字数分ループする For n = 1 To Len(str2) Step 4 '4文字(1バイト)単位にループを作る n8421 = 8 '初期値に8を代入する(上から計算したいので) nBYTE = 0 '1バイト計算用変数を初期化 For i = 0 To 3 '4回まわるよ(4ビット分) 'ビットが立っているかチェックする If Mid(str2, n + i, 1) = "1" Then nBYTE = nBYTE + n8421 'ビットに対応した数値を+する End If '次のビットを計算したいので2で割る n8421 = n8421 / 2 Next '計算して、1倍との数値が完成したので16進文字にしてセットする strHEX = strHEX & Hex(nBYTE) Next