| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 4032 人关注过本帖
标题:[求助]用vb模拟点击网页按钮问题
只看楼主 加入收藏
wyfandy
Rank: 1
来 自:深圳
等 级:新手上路
帖 子:376
专家分:0
注 册:2006-12-11
收藏
 问题点数:0 回复次数:9 
[求助]用vb模拟点击网页按钮问题

我想利用Webbrowser获取http://www.cma.gov.cn/(中国气象局)的天气
可是不能不知道为什么模拟点提交的时候直本不能提交只能手工点提交才能成功.
但其它网可以实现用程序模拟提交,这我百思不得其解,请各位指点。

Private Sub Command1_Click()
Dim doc As IHTMLDocument2
Set doc = WebBrowser1.Document

If Form1.Caption = "http://www.cma.gov.cn/tqyb/weatherdetail/54511.html" Then
Dim Inputs As IHTMLElementCollection
Set Inputs = doc.All.tags("INPUT")
Dim Element As IHTMLElement
Set Element = Inputs.Item(2, 0)

Dim InputElement As IHTMLInputElement
Set InputElement = Element
InputElement.Value = Text1.Text

doc.Forms.Item(3, 0).submit '模拟点"提交"按钮
End If
End Sub

Private Sub Form_Load()
WebBrowser1.Navigate2 "http://www.cma.gov.cn/tqyb/weatherdetail/54511.html"
End Sub

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Form1.Caption = URL
End Sub

红色字体处模拟点"提交"
源程序

SVFpCnOP.rar (2.37 KB) 用vb如何模拟点击按钮


[此贴子已经被作者于2006-12-18 14:08:06编辑过]

搜索更多相关主题的帖子: 网页 gov 按钮 cma 
2006-12-16 20:10
wyfandy
Rank: 1
来 自:深圳
等 级:新手上路
帖 子:376
专家分:0
注 册:2006-12-11
收藏
得分:0 
怎么没有高手指点啊?

[此贴子已经被作者于2006-12-17 20:59:51编辑过]



不论什么事,只要认准了一个目标,然后朝之不懈地努力,就一定实现。编程爱好者QQ群:21318556
2006-12-17 09:59
google
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:22
帖 子:3419
专家分:23
注 册:2005-11-1
收藏
得分:0 
楼主还是开个金钱贴吧

祝天下所有母亲幸福安康!~
2006-12-18 15:39
学习VB才2天
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:1653
专家分:0
注 册:2006-5-4
收藏
得分:0 
沒用過````妳用個SENDKEY試試````

[GLOW=255,DeepPink,3]我的免费网盘[/GLOW]
2006-12-18 15:41
ioriliao
Rank: 7Rank: 7Rank: 7
来 自:广东
等 级:贵宾
威 望:32
帖 子:2829
专家分:647
注 册:2006-11-30
收藏
得分:0 
以下是引用wyfandy在2006-12-17 9:59:17的发言:
怎么没有高手指点啊?

wyfandy:
是否我们要转移阵地了...除了"学习vb才两天"都没有热心的人了!


/images/2011/147787/2011051411021524.jpg" border="0" />
2006-12-18 16:01
Knocker
Rank: 8Rank: 8
等 级:贵宾
威 望:47
帖 子:10454
专家分:603
注 册:2004-6-1
收藏
得分:0 

[QUOTE]<script language="JavaScript">
var chinaprovinces=document.weather.province.options.length /////该省份在数组中的索引
var c=new Array(chinaprovinces); /////////////实例化长度是chinaprovinces的数组
var n=new Array(chinaprovinces);
for (i=0; i<chinaprovinces; i++) c[i]=new Array();
c[0] = new Array("选择城市");
c[1] = new Array("选择城市","北京","上海","天津","重庆");
c[2] = new Array("选择城市","香港","澳门");
c[3] = new Array("选择城市","哈尔滨","齐齐哈尔","牡丹江","大庆","伊春","双鸭山","鹤岗","鸡西","佳木斯","七台河","黑河","绥化","大兴安岭");
c[4] = new Array("选择城市","长春","延边","吉林","白山","白城","四平","松原","辽源","大安","通化");
c[5] = new Array("选择城市","沈阳","大连","葫芦岛","旅顺","本溪","抚顺","铁岭","辽阳","营口","阜新","朝阳","锦州","丹东","鞍山");
c[6] = new Array("选择城市","呼和浩特","呼伦贝尔","锡林浩特","包头","赤峰","海拉尔","乌海","鄂尔多斯","锡林浩特","通辽");
c[7] = new Array("选择城市","石家庄","唐山","张家口","廊坊","邢台","邯郸","沧州","衡水","承德","保定","秦皇岛");
c[8] = new Array("选择城市","郑州","开封","洛阳","平顶山","焦作","鹤壁","新乡","安阳","濮阳","许昌","漯河","三门峡","南阳","商丘","信阳","周口","驻马店");
c[9] = new Array("选择城市","济南","青岛","淄博","威海","曲阜","临沂","烟台","枣庄","聊城","济宁","菏泽","泰安","日照","东营","德州","滨州","莱芜","潍坊");
c[10] = new Array("选择城市","太原","阳泉","晋城","晋中","临汾","运城","长治","朔州","忻州","大同");
c[11] = new Array("选择城市","南京","苏州","昆山","南通","太仓","吴县","徐州","宜兴","镇江","淮安","常熟","盐城","泰州","无锡","连云港","扬州","常州","宿迁");
c[12] = new Array("选择城市","合肥","巢湖","蚌埠","安庆","六安","滁州","马鞍山","阜阳","宣城","铜陵","淮北","芜湖","毫州","宿州","淮南","池州");
c[13] = new Array("选择城市","西安","韩城","安康","汉中","宝鸡","咸阳","榆林","渭南","商洛","铜川","延安");
c[14] = new Array("选择城市","银川","固原","中卫","石嘴山","吴忠");
c[15] = new Array("选择城市","兰州","白银","庆阳","酒泉","天水","武威","张掖","甘南","临夏","平凉","定西","金昌");
c[16] = new Array("选择城市","西宁","海北","海西","黄南","果洛","玉树","海东","海南");
c[17] = new Array("选择城市","武汉","宜昌","黄冈","恩施","荆州","神农架","十堰","咸宁","襄樊","孝感","随州","黄石","荆门","鄂州");
c[18] = new Array("选择城市","长沙","邵阳","常德","郴州","吉首","株洲","娄底","湘潭","益阳","永州","岳阳","衡阳","怀化","韶山","张家界");
c[19] = new Array("选择城市","杭州","湖州","金华","宁波","丽水","绍兴","雁荡山","衢州","嘉兴","台州","舟山","温州");
c[20] = new Array("选择城市","南昌","萍乡","九江","上饶","抚州","吉安","鹰潭","宜春","新余","景德镇","赣州");
c[21] = new Array("选择城市","福州","厦门","龙岩","南平","宁德","莆田","泉州","三明","漳州");
c[22] = new Array("选择城市","贵阳","安顺","赤水","遵义","铜仁","六盘水","毕节","凯里","都匀");
c[23] = new Array("选择城市","成都","泸州","内江","凉山","阿坝","巴中","广元","乐山","绵阳","德阳","攀枝花","雅安","宜宾","自贡","甘孜州","达州","资阳","广安","遂宁","眉山","南充");
c[24] = new Array("选择城市","广州","深圳","潮州","韶关","湛江","惠州","清远","东莞","江门","茂名","肇庆","汕尾","河源","揭阳","梅州","中山","德庆","阳江","云浮","珠海","汕头");
c[25] = new Array("选择城市","南宁","桂林","阳朔","柳州","梧州","玉林","桂平","贺州","钦州","贵港","防城港","百色","北海","河池","来宾","崇左");
c[26] = new Array("选择城市","昆明","保山","楚雄","德宏","红河","临沧","怒江","曲靖","思茅","文山","玉溪","昭通","丽江","大理");
c[27] = new Array("选择城市","海口","三亚","儋州","琼山","通什","文昌");
c[28] = new Array("选择城市","乌鲁木齐","阿勒泰","阿克苏","昌吉","哈密","和田","喀什","克拉玛依","石河子","塔城","库尔勒","吐鲁番");
c[29] = new Array("选择城市","拉萨","阿里","昌都","那曲","日喀则","山南","林芝");
c[30] = new Array("选择城市","台北","高雄");
for (i=0; i<chinaprovinces; i++) n[i]=new Array();
n[0] = new Array("0");
n[1] = new Array("0","54511","58367","54517","57516");
n[2] = new Array("0","45005","45011");
n[3] = new Array("0","50953","50745","54094","50842","50774","50884","50775","50978","50873","50971","50468","50853","50442");
n[4] = new Array("0","54161","99999","54172","54371","50936","54157","50946","54260","50945","54363");
n[5] = new Array("0","54342","54662","54453","54660","54346","54353","54249","54347","54471","54237","54324","54337","54497","54339");
n[6] = new Array("0","53463","99999","54102","53446","54218","50527","53512","53543","54102","54135");
n[7] = new Array("0","53698","54534","54401","54515","53798","53892","54616","54702","54423","54602","54449");
n[8] = new Array("0","57083","57091","57073","57171","53982","53990","53986","53898","54900","57089","57186","57051","57178","58005","57297","57195","57290");
n[9] = new Array("0","54823","54857","54830","54774","54918","54938","54765","58024","54806","54915","54906","54827","54945","54736","54714","54734","54828","54843");
n[10] = new Array("0","53772","53782","53976","53778","53868","53959","53882","53578","53674","53487");
n[11] = new Array("0","58238","58357","58356","58259","58377","58349","58027","58346","58248","58145","58352","58151","58246","58354","58044","58245","58343","58131");
n[12] = new Array("0","58321","58326","58221","58424","58311","58236","58336","58203","58433","58429","58116","58334","99999","58122","58224","58427");
n[13] = new Array("0","57036","53955","57245","57127","57016","57048","53646","57045","57143","53947","53845");
n[14] = new Array("0","53614","53817","53704","53518","53612");
n[15] = new Array("0","52889","52896","53829","52533","57006","52679","52652","50741","52984","53915","52995","52675");
n[16] = new Array("0","52866","52754","52737","56065","56043","56029","52875","52856");
n[17] = new Array("0","57494","57461","57498","57447","57476","57362","57256","57590","57278","57482","57381","58407","57377","57496");
n[18] = new Array("0","57687","57766","57662","57972","57649","57780","57763","57773","99999","57866","57584","57872","57749","57771","57558");
n[19] = new Array("0","58457","58450","58549","58563","58646","58453","99999","58633","58452","58660","58477","58659");
n[20] = new Array("0","58606","57786","58502","58637","58617","57799","58627","57793","57796","58527","57993");
n[21] = new Array("0","58847","59134","58927","58834","58846","58946","59137","58828","59126");
n[22] = new Array("0","57816","57806","57609","57713","57741","56693","57707","57825","57827");
n[23] = new Array("0","56294","57602","57504","56571","56171","57313","57206","56386","56196","56198","56666","56287","56492","56396","56146","57328","56298","57415","57405","56391","57411");
n[24] = new Array("0","59287","59493","59312","59082","59658","59298","59280","59289","59473","59659","59278","59501","59293","59315","59117","59485","59269","59663","59471","59488","59316");
n[25] = new Array("0","59431","57957","59051","59046","59265","59453","59254","59065","59632","59249","59635","59211","59644","59023","59242","59425");
n[26] = new Array("0","56778","56748","56768","56844","56975","56951","56533","56783","56964","56994","56875","56586","56651","56751");
n[27] = new Array("0","59758","59948","59845","59757","59941","59856");
n[28] = new Array("0","51463","51076","51628","51368","52203","51828","51709","51243","51356","51133","51656","51573");
n[29] = new Array("0","55591","55437","56137","55299","55578","55598","56312");
n[30] = new Array("0","58968","59554");[/QUOTE]

你不要去模拟点击,而应该直接在你的程序中把URL计算出来


九洲方除百尺冰,映秀又遭蛮牛耕。汽笛嘶鸣国旗半,哀伤尽处是重生。     -老K
治国就是治吏。礼义廉耻,国之四维。四维不张,国之不国。   -毛泽东
2006-12-18 16:24
学习VB才2天
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:1653
专家分:0
注 册:2006-5-4
收藏
得分:0 
`````老K  ```這裏是VB區````不過```貌似用JAVASCRIPT也行```但是````鉨的內容好像對初學者來說是天書```

[GLOW=255,DeepPink,3]我的免费网盘[/GLOW]
2006-12-18 16:35
Knocker
Rank: 8Rank: 8
等 级:贵宾
威 望:47
帖 子:10454
专家分:603
注 册:2004-6-1
收藏
得分:0 
晕死,这是楼主要处理的网页中的部分源码,从这一部分可以看出如何从地名换算URL

九洲方除百尺冰,映秀又遭蛮牛耕。汽笛嘶鸣国旗半,哀伤尽处是重生。     -老K
治国就是治吏。礼义廉耻,国之四维。四维不张,国之不国。   -毛泽东
2006-12-18 19:27
kiso1234
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2006-12-16
收藏
得分:0 
把你红色部分改为
For i = 0 To Inputs.length - 1
If Inputs(i).Value = "提交" Then Inputs(i).Click
Next i
qyljNhxT.rar (2.5 KB)

[此贴子已经被作者于2006-12-18 20:44:21编辑过]

2006-12-18 20:43
wyfandy
Rank: 1
来 自:深圳
等 级:新手上路
帖 子:376
专家分:0
注 册:2006-12-11
收藏
得分:0 

非常感谢各位热诚的帮忙,这个问题终于解决了

6楼的方法是好就是太过复杂了点10楼的方法简单.

[此贴子已经被作者于2006-12-19 10:55:02编辑过]


不论什么事,只要认准了一个目标,然后朝之不懈地努力,就一定实现。编程爱好者QQ群:21318556
2006-12-19 10:51
快速回复:[求助]用vb模拟点击网页按钮问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.040087 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved