返回列表 发帖

[问题求助] VBS如何获取多玩LOL英雄联盟战绩查询网页中的某些数据?

本帖最后由 pcl_test 于 2016-9-12 21:23 编辑

网页如下:
http://lolbox.duowan.com/playerD ... 6%E5%B9%B2%E7%88%B9

如何获取这个网页中的一些数据:
1.被赞次数,被拉黑次数
2.战斗力
3.最近常玩英雄的图片URL
4.匹配模式->经典模式 的总场次,胜率,胜场和负场
5.S4排位赛->5v5单双排 的段位/级别,胜点,总场次,胜率,胜场和负场

想自己做个页面调用这个网页里面的这些数据,大神帮下,谢了。

从源码中获取这些数据倒是简单,就是不知如何把能网页源码下载下来

TOP

源码下载下来不是可以用wget -q -O 1.htm 网页地址?

TOP

举例:
url = "http://lolbox.duowan.com/playerDetail.php?serverName=%E5%AE%88%E6%9C%9B%E4%B9%8B%E6%B5%B7&playerName=%E6%88%91%E6%98%AF%E4%BB%96%E5%B9%B2%E7%88%B9"
Set http = CreateObject("MSXML2.XMLHTTP")
http.Open "GET", url, false
http.Send
pattern = "(被赞|被拉黑) +(\d+)|>(战斗力)<[\s\S]*?>(\d+)<"
MsgBox  GetData(http.ResponseBody, pattern)
Function GetData(bin, ByVal pattern)
        with CreateObject("ADODB.Stream")
                .Mode = 3
                .Type = 1
                .Open
                .Write bin
                .Position = 0
                .Type = 2
                .Charset = "utf-8"
                txt = .ReadText
        End with
        Set re = New RegExp
        re.Pattern = pattern
        re.Global = true
        For Each m in re.Execute(txt)
                If m.SubMatches(0) <> "" Then
                        s = s & m.SubMatches(0) & vbTab
                        s = s & m.SubMatches(1) & vbCrLf
                Else
                        s = s & m.SubMatches(2) & vbTab
                        s = s & m.SubMatches(3) & vbCrLf
                End If
        Next
        GetData = s
End FunctionCOPY

TOP

建议学学python 有点基础的话一天就能搞定
用urllib和beautifulsoup敲不了几行代码全都搞定
!scripting!

TOP

借用胖大师的正则,也举个例,用 php 试试:
php -r "preg_match_all('/(被赞|被拉黑) +(\d+)|>(战斗力)<[\s\S]*?>(\d+)</',iconv('utf-8','gbk',file_get_contents($argv[1])),$match);foreach($match as $a){echo $a[1],$a[2];}"                   "http://lolbox.duowan.com/playerDetail.php?serverName=%E5%AE%88%E6%9C%9B%E4%B9%8B%E6%B5%B7&playerName=%E6%88%91%E6%98%AF%E4%BB%96%E5%B9%B2%E7%88%B9" COPY

TOP

谢谢楼上的几位朋友,被赞和战斗力,以及其他一些把网页download下来之后用批处理我都能分析出来,现在不知道的是他的段位以及胜点是怎么来的

TOP

回复 4# apang


    好历害的感觉.......

    老师,能帮帮忙忙写个提取页信息的 VBS 代码不?
    谢谢了!

    http://www.bathome.net/viewthrea ... 26amp%3Btypeid%3D58
☆★I wait for you!☆★

TOP

Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = true
ie.navigate "http://lolbox.duowan.com/playerDetail.php?serverName=%E5%AE%88%E6%9C%9B%E4%B9%8B%E6%B5%B7&playerName=%E6%88%91%E6%98%AF%E4%BB%96%E5%B9%B2%E7%88%B9"
Do
WSH.Sleep 500
Loop Until ie.readyState = 4
info = ""
For Each div in ie.Document.getElementsByTagName("div")
  If div.className = "text" Then info = info & replace(div.innerText, vbCrLf, " ")
  If div.className = "fighting" Then info =info & " " & replace(div.innerText, vbCrLf, " ") & vbCrLf
  If div.className = "com-hero" Then
      info = info & div.getElementsByTagName("h3")(0).innerText & ":" & vbCrLf
      For Each img in div.getElementsByTagName("img")
          info = info & img.src & vbCrLf
      Next
  End If
  If div.className = "mod-tabs" Then
      Set table = div.getElementsByTagName("table")
      For Each td in table(0).getElementsByTagName("tr")(1).getElementsByTagName("td")
          info = info & td.innerText & " "
      Next
      info = info & vbCrLf
      For Each td in table(1).getElementsByTagName("tr")(1).getElementsByTagName("td")
          info = info & td.innerText & " "
      Next
  End If
Next
msgbox info
ie.quitCOPY

TOP

返回列表