ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 效率神器,一键搞定繁琐工作
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
让更多数据处理,一键完成 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
楼主: onlycxb

[分享] 网页抓取分享

  [复制链接]

TA的精华主题

TA的得分主题

发表于 2014-10-21 16:44 | 显示全部楼层
onlycxb 发表于 2014-10-14 19:16
分享5:阳光私募净值
后期数据处理过程请自学者自行完善。

ie法提取代码如下:

Sub 阳光募捐数据提取()
Cells.ClearContents
Dim p%, tp As Long, i%, j%, t, r As Object

With CreateObject("internetexplorer.application")
    .Visible = True
    .Navigate "http://www.go-goal.com/data/trust"
    Do Until .readyState = 4
        DoEvents
    Loop
   
    t = Timer
    Do While t + 2 > Timer
        DoEvents
    Loop
    tp = Split(Split(.Document.all.tags("span")(17).innerText, "共 ")(2), " 页")(0) '此句显示总页数
    Cells(1, 20) = tp
    For p = 1 To 2
        t = Timer
        Do While t + 2 > Timer
            DoEvents
        Loop
        
        Set r = .Document.all.tags("table")(10).Rows
        For i = 0 To r.Length - 1
            For j = 0 To r(i).Cells.Length - 1
                Cells((p - 1) * 21 + i + 1, j + 1) = r(i).Cells(j).innerText
            Next j
        Next i
   
        .Document.all.tags("a")(118).Click
    Next p
End With
End Sub

TA的精华主题

TA的得分主题

 楼主| 发表于 2014-10-21 17:10 | 显示全部楼层
VBA万岁 发表于 2014-10-21 15:54
测试通过,多谢分享!
添加引用如59楼,
Mark如附件:

分享暂时到此,我去听课去了,地址。http://club.excelhome.net/thread-1159783-1-1.html

TA的精华主题

TA的得分主题

发表于 2014-10-21 17:11 | 显示全部楼层
VBA万岁 发表于 2014-10-21 16:44
ie法提取代码如下:

Sub 阳光募捐数据提取()

附件如下:
阳光募捐数据提取.zip (400.87 KB, 下载次数: 30)

TA的精华主题

TA的得分主题

发表于 2014-10-21 17:16 | 显示全部楼层
onlycxb 发表于 2014-10-21 17:10
分享暂时到此,我去听课去了,地址。http://club.excelhome.net/thread-1159783-1-1.html

多谢指点!
我也得进去听听课了......

TA的精华主题

TA的得分主题

发表于 2014-10-31 10:56 | 显示全部楼层
本帖最后由 VBA万岁 于 2014-10-31 10:58 编辑
onlycxb 发表于 2014-10-14 07:57
分享2:抓取北京地铁1号线站名及换乘区间


onlycxb大侠,我有一个疑问:
我将1、3楼代码中的responseText数据分别复制到了两个Word文档(详见以下附件)中,结果发现,它们全是由英文字符及数字组成,而不像6楼的responseText数据那样直接含有待提取的数据,如“地铁1号线(四惠东-苹果园)”等中文字符串。
想知道你是如何通过 js.eval 而得到最终数据的?

responseText.zip (32.96 KB, 下载次数: 7)

TA的精华主题

TA的得分主题

 楼主| 发表于 2014-10-31 10:58 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
VBA万岁 发表于 2014-10-31 10:56
onlycxb大侠,我有一个疑问:
我将1、3楼代码中的responseText数据分别复制到了两个Word文档中,结果发现 ...

复制的数据是不全的,建议将数据粘贴到记事本中。

TA的精华主题

TA的得分主题

 楼主| 发表于 2014-10-31 10:59 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
分享的代码,一些测试分析过程的代码省略了。这个自己分析并获取才明白。

TA的精华主题

TA的得分主题

发表于 2014-10-31 11:00 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
onlycxb 发表于 2014-10-31 10:58
复制的数据是不全的,建议将数据粘贴到记事本中。

数据粘贴到记事本中也是一样只见英文字符串而不见中文。

TA的精华主题

TA的得分主题

 楼主| 发表于 2014-10-31 11:01 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
Sub CopyToClipbox(strText As String)
    '文本拷贝到剪贴板
    With CreateObject("new:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
        .SetText strText
        .PutInClipboard
    End With
End Sub

TA的精华主题

TA的得分主题

 楼主| 发表于 2014-10-31 11:12 | 显示全部楼层
VBA万岁 发表于 2014-10-31 11:00
数据粘贴到记事本中也是一样只见英文字符串而不见中文。

debug.print .responsetext
数据如下,经过转码可得到想要的数据:
{"place_info":{"d_activity_gwj_section":"0-+","d_brand_id_section":"0-+","d_business_id":"","d_business_type":"","d_cater_book_pc_section":"0-+","d_cater_book_wap_section":"0-+","d_cater_rating_section":"0-+","d_data_type":"","d_discount2_section":"0-+","d_discount_section":"0-+","d_discount_tm2_section":"0-+","d_discount_tm_section":"0-+","d_dist":"0-+","d_filt_type_section":"0-+","d_free_section":"0-+","d_groupon_section":"0-+","d_groupon_type_section":"0-+","d_health_score_section":"0-+","d_hotel_book_pc_section":"0-+","d_hotel_book_wap_section":"0-+","d_level_section":"0-+","d_lowprice_flag_section":"0-+","d_movie_book_section":"0-+","d_overall_rating_section":"0-+","d_price_section":"0-+","d_query_attr_type":"4","d_rebate_section":"0-+","d_sort_rule":"0","d_sort_type":"","d_spothot_section":"0-+","d_sub_type":"","d_support_imax_section":"0-+","d_tag_filter":"0","d_tag_info_list":"\u4ea4\u901a\u8bbe\u65bd,\u5730\u94c1\u7ad9","d_ticket_book_flag_section":"0-+","d_tonight_sale_flag_section":"0-+","d_total_
score_section":"0-+","d_wise_price_section":"0-+","search_ext":[{"title":"","wd":""}]},"content":[{"acc_flag":1,"area":131,"biz_type":0,"catalogID":905,"cla":[[903,"\u516c\u4ea4\u7ebf\u8def"],[905,"<font color=\"#c60a00\">\u5730\u94c1<\/font>,\u8f7b\u8f68"]],"cp":"bus","detail":0,"dis":-1,"dist2route":0,"dist2start":0,"ext":[{"info":"","price_ext":"","time_ext":"","timetable_ext":"","update_time":"","username":""}],"ext_type":8,"f_flag":5,"father_son":0,"geo":"1|12971354.88,4825923.53;12971354.88,4825923.53|12971354.88,4825923.53;","geo_type":1,"name":"\u5730\u94c11\u53f7\u7ebf(\u56db\u60e0\u4e1c-\u82f9\u679c\u56ed)","poiType":4,"poi_profile":0,"primary_uid":"1557622","route_flag":0,"show_tag":[],"status":1,"storage_src":"index","tag":"","ty":1,"uid":"bce557d6f7fadd4ea5da39b7","view_type":0,"x":1297135488,"y":482592353},{"acc_flag":1,"area":131,"biz_type":0,"catalogID":905,"cla":[[903,"\u516c\u4ea4\u7ebf\u8def"],[905,"<font color=\"#c60a00\">\u5730\u94c1<\/font>,\u8f7b\u8f68"]],"cp":"bus","detail":0,"dis":-1
,"dist2route":0,"dist2start":0,"ext":[{"info":"","price_ext":"","time_ext":"","timetable_ext":"","update_time":"","username":""}],"ext_type":8,"f_flag":5,"father_son":0,"geo":"1|12933692.29,4828438.13;12933692.29,4828438.13|12933692.29,4828438.13;","geo_type":1,"name":"\u5730\u94c11\u53f7\u7ebf(\u82f9\u679c\u56ed-\u56db\u60e0\u4e1c)","poiType":4,"poi_profile":0,"primary_uid":"1557614","route_flag":0,"show_tag":[],"status":1,"storage_src":"index","tag":"","ty":1,"uid":"3e210d94b51b7a184107c1b7","view_type":0,"x":1293369229,"y":482843813},{"acc_flag":0,"addr":"\u56fd\u8d38\u5411\u4e1c\u4e24\u516c\u91cc\u5730\u94c1\u4e00\u53f7\u7ebf\u56db\u60e0\u81f3\u56db\u60e0\u4e1c\u7ad9\u4e4b\u95f4\u5730\u94c1\u4e0a\u65b9\u58f9\u7ebf\u56fd\u9645","alias":["\u9996\u5f00\u58f9\u7ebf\u56fd\u9645\u5546\u4e1a\u5e7f\u573a","\u58f9\u7ebf\u56fd\u9645(\u901a\u60e0\u5bb6\u56ed\u897f\u5357)","\u58f9\u7ebf\u56fd\u9645\u5546\u4e1a\u5e7f\u573a"],"aoi":"\u56db\u60e0","area":2898,"biz_type":0,"catalogID":238,"cla":[[25,"\u5730\u4ea7\u5c0f\
u533a"],[238,"\u5c0f\u533a\/\u697c\u76d8"]],"detail":1,"dis":-1,"dist2route":0,"dist2start":0,"ext"}}

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

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2025-1-12 06:13 , Processed in 0.026487 second(s), 8 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

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