[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[问题求助] 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

举例:
  1. 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"
  2. Set http = CreateObject("MSXML2.XMLHTTP")
  3. http.Open "GET", url, false
  4. http.Send
  5. pattern = "(被赞|被拉黑) +(\d+)|>(战斗力)<[\s\S]*?>(\d+)<"
  6. MsgBox  GetData(http.ResponseBody, pattern)
  7. Function GetData(bin, ByVal pattern)
  8.         with CreateObject("ADODB.Stream")
  9.                 .Mode = 3
  10.                 .Type = 1
  11.                 .Open
  12.                 .Write bin
  13.                 .Position = 0
  14.                 .Type = 2
  15.                 .Charset = "utf-8"
  16.                 txt = .ReadText
  17.         End with
  18.         Set re = New RegExp
  19.         re.Pattern = pattern
  20.         re.Global = true
  21.         For Each m in re.Execute(txt)
  22.                 If m.SubMatches(0) <> "" Then
  23.                         s = s & m.SubMatches(0) & vbTab
  24.                         s = s & m.SubMatches(1) & vbCrLf
  25.                 Else
  26.                         s = s & m.SubMatches(2) & vbTab
  27.                         s = s & m.SubMatches(3) & vbCrLf
  28.                 End If
  29.         Next
  30.         GetData = s
  31. End Function
复制代码

TOP

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

TOP

借用胖大师的正则,也举个例,用 php 试试:
  1. 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"
复制代码

TOP

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

TOP

回复 4# apang


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

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

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

TOP

  1. Set ie = CreateObject("InternetExplorer.Application")
  2. ie.Visible = true
  3. 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"
  4. Do
  5. WSH.Sleep 500
  6. Loop Until ie.readyState = 4
  7. info = ""
  8. For Each div in ie.Document.getElementsByTagName("div")
  9.   If div.className = "text" Then info = info & replace(div.innerText, vbCrLf, " ")
  10.   If div.className = "fighting" Then info =info & " " & replace(div.innerText, vbCrLf, " ") & vbCrLf
  11.   If div.className = "com-hero" Then
  12.       info = info & div.getElementsByTagName("h3")(0).innerText & ":" & vbCrLf
  13.       For Each img in div.getElementsByTagName("img")
  14.           info = info & img.src & vbCrLf
  15.       Next
  16.   End If
  17.   If div.className = "mod-tabs" Then
  18.       Set table = div.getElementsByTagName("table")
  19.       For Each td in table(0).getElementsByTagName("tr")(1).getElementsByTagName("td")
  20.           info = info & td.innerText & " "
  21.       Next
  22.       info = info & vbCrLf
  23.       For Each td in table(1).getElementsByTagName("tr")(1).getElementsByTagName("td")
  24.           info = info & td.innerText & " "
  25.       Next
  26.   End If
  27. Next
  28. msgbox info
  29. ie.quit
复制代码

TOP

返回列表