返回列表 发帖
应该放在VBS出题区比较好吧?
而且也没有什么挑战性,会VBS且会xmlhttp、adodb.stream、DOM等常见“第三方”对象的使用,本题迎刃而解,关键是要知道那几个对象。

其实我想问这个问题:如何用vbs从图片中读出验证码(如果有人研究出来了,肯定不能随便公开^@^)

TOP

【悟空道:“但凭尊师教诲,只是有些道气儿,弟子便就学了。”】与【只是有些道气儿】
如果短句子在前面呢?怎么处理?

TOP

vbs
Set fso = CreateObject("Scripting.FileSystemObject")
Set dict = CreateObject("Scripting.Dictionary")
downloader "http://bbs.tt365.net.cn/viewthread.php?tid=161145", "E:\test\aaa.htm"
Set oDOM = GetObject("E:\test\aaa.htm", "htmlfile")
Do Until oDOM.readyState="complete" : WScript.Sleep 200 : Loop 'complete
Set tags = oDOM.getElementsByTagName("td")
for each tag in tags
    if 1=InStr(tag.Id,"postmessage_") then
        'WScript.echo tag.innerText
        StrStrReg tag.innerText, "【([^【】]+)】"
    end if
next
Set ts = fso.OpenTextFile("result.txt", 2, true)
for each key in dict.Keys()
    'WScript.echo key
    ts.WriteLine key
next
ts.Close()
function downloader(url, file)
  dim XMLHTTP, AdoStrm
  Set XMLHTTP = CreateObject("Microsoft.XMLHTTP")
  XMLHTTP.Open "GET", url, false
  XMLHTTP.Send()
  set AdoStrm = CreateObject("ADODB.Stream")
  AdoStrm.Mode = 3
  AdoStrm.Type = 1
  AdoStrm.Open()
  AdoStrm.Write XMLHTTP.ResponseBody
  AdoStrm.SaveToFile file, 2
end function
function StrStrReg(srcStr, subStr)
  dim regEx, Matches, Match, ret
  set regEx = CreateObject("VBScript.RegExp")
  regEx.Pattern = subStr
  regEx.Global = true
  regEx.IgnoreCase = false
  set Matches = regEx.execute(srcStr)
  for each Match in Matches
    'ret = ret & Match.subMatches(0) & vbCrLf
    Catch Match.subMatches(0)
  next
  StrStrReg = ret
end function
function Catch(txt)
  for each key in dict.Keys()
    if InStr(key,txt) then exit function
  next
  dict.Add txt, 1
end functionCOPY
1

评分人数

    • batman: 没想到vbs正则真的做到了PB + 20

TOP

返回列表