本次介紹的方法是http://chiensq.blog.163.com/blog/static/1035628201174015765/?newFollowBlog中介紹的第二種方法控制網(wǎng)頁(yè) 要填寫(xiě)網(wǎng)頁(yè)表單,就要知道網(wǎng)頁(yè)中各個(gè)要填寫(xiě)的項(xiàng)目名稱,就需要分析網(wǎng)頁(yè)。分析網(wǎng)頁(yè)有好幾種方法: 以:http://mial.163.com/為例 1、直接查看網(wǎng)頁(yè)的源代碼(網(wǎng)頁(yè)右鍵有該功能) 在源代碼中直接搜索如“用戶名”,“密碼”等需要填寫(xiě)的項(xiàng)目的文字。找到類似以下的代碼 <LABEL class="lb for for-1">用戶名</LABEL> <LABEL class="lb for for-2 for-3">手機(jī)號(hào)</LABEL> <INPUT class=ipt-t id=idInput onblur="fCheckAccount(this);fEvent('blur',this)" onmouseover="fEvent('mouseover',this)" onfocus="fEvent('focus',this)" tabIndex=1 onmouseout="fEvent('mouseout',this)" maxLength=50 name=username autocomplete="off" isfocus="false"> <SPAN class=domain>@163.com</SPAN> 將該代碼分段 ?<LABEL class="lb for for-1">用戶名</LABEL>????????????? --是顯示“用戶名”的文字的表格,并不是輸入項(xiàng)目 ?<LABEL class="lb for for-2 for-3">手機(jī)號(hào)</LABEL>?? --是顯示“用戶名”的文字的表格,并不是輸入項(xiàng)目 而已INPUT開(kāi)始的就是需要輸入的項(xiàng)目,發(fā)現(xiàn)有name=username的代碼,意思是用戶名就是username,這就是我們要找的。 一般都是找 ID= 或者 name = 。 ?<INPUT class=ipt-t id=idInput onblur="fCheckAccount(this);fEvent('blur',this)" onmouseover="fEvent('mouseover',this)" onfocus="fEvent('focus',this)" tabIndex=1 onmouseout="fEvent('mouseout',this)" maxLength=50 name=username autocomplete="off" isfocus="false"> ?2、但是項(xiàng)目多的話,這樣找比較麻煩,也可以用VBA代碼直接找 引用老狼的代碼:http://blog.csdn.net/northwolves/article/details/1809109 Sub show163tags() Dim i As Byte With CreateObject("InternetExplorer.Application") .Visible = True .navigate "Do Until .Readystate = 4 DoEvents Loop On Error Resume Next For i = 1 To 100 If Len(.Document.Forms(0).All(i).Name) > 0 Then Debug.Print "i=" & i; "? name=" & .Document.Forms(0).All(i).Name Next End With MsgBox "ok" End Sub 3、但是有的項(xiàng)目是沒(méi)有ID和Name的,就比如163郵箱這個(gè)button即沒(méi)ID又沒(méi)name。 這個(gè)時(shí)候可以用到索引號(hào),手工找就不介紹了,直接推薦用Ldy的分析工具 http://club.excelhome.net/thread-377077-1-1.html ? 參考文章 http://club.excelhome.net/thread-719242-1-1.html |
新跟帖 (共1 條評(píng)論)
查看更多評(píng)論。。。