Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1048|回复: 6

VBA爬数据元素怎么用Split替换

[复制链接]
发表于 2022-6-4 23:58 | 显示全部楼层 |阅读模式
3学分
  1. Sub zhua()
  2.   
  3.   '创建对象
  4.   Dim xmlHttp As Object
  5.   Set xmlHttp = CreateObject("MSXML2.XMLHTTP")
  6.   '发送请求
  7.   xmlHttp.Open "GET", "https://d998cp.cc/result/HF_HNWFC", False
  8.   xmlHttp.send
  9.   
  10.   '等待响应
  11.   Do While xmlHttp.ReadyState <> 4
  12.   DoEvents
  13.   Loop
  14.   '得到请求数据
  15.   Dim Myhtml As String
  16.   Myhtml = xmlHttp.responseText
  17.   Dim jg As String
  18.   jg = Split(Split(Myhtml, "<table class=""table___2m6aC"">")(1), "</td>")(0)
  19.   Range("a2").Resize(UBound(jg), 6) = jg
  20. End Sub
复制代码
   Split(Split(Myhtml, "<table class=""table___2m6aC"">")(1), "</td>")(0)这一句搞不懂字母截取数据,找到网页元素途径,填着不对,都是网页开头
大佬帮我搞下,怎么抓取数据

下面附件是样板
爬数据.rar (12.03 KB, 下载次数: 11)

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2022-6-6 21:50 | 显示全部楼层
数据在
https://d998cp.cc/api/v1/result/service/mobile/results/histByDate?gameUniqueId=HF_HNWFC&date=2022-06-06&brand=998
date=日期
回复

使用道具 举报

发表于 2022-6-6 21:51 | 显示全部楼层
你这网站很什么哦,我是翻墙才能登上去
回复

使用道具 举报

 楼主| 发表于 2022-6-7 14:22 | 显示全部楼层
eennoo 发表于 2022-6-6 21:51
你这网站很什么哦,我是翻墙才能登上去

不用墙啊,国内的
回复

使用道具 举报

 楼主| 发表于 2022-6-7 14:38 | 显示全部楼层
eennoo 发表于 2022-6-6 21:50
数据在
https://d998cp.cc/api/v1/result/service/mobile/results/histByDate?gameUniqueId=HF_HNWFC&date ...

https://manycai.tj/#/lottery?lotteryId=48
这个能直接抓20页吗?

回复

使用道具 举报

发表于 2022-6-7 23:42 | 显示全部楼层
https://manycai.tj/rest/lottery/list?_=&lotteryId=37&current=1&pageSize=15
current=页数
你要自己会捉网呢,我就用360浏览器,按F12就可以捉网了,
回复

使用道具 举报

 楼主| 发表于 2022-6-8 14:10 | 显示全部楼层
eennoo 发表于 2022-6-7 23:42
https://manycai.tj/rest/lottery/list?_=&lotteryId=37&current=1&pageSize=15
current=页数
你要自己会 ...

你这个式异常500
id加 页数 加单页15,动态会变

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-5-25 19:01 , Processed in 0.973935 second(s), 7 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表