標題:
[發問]
網頁登入-按鈕問題!
[打印本頁]
作者:
die78325
時間:
2012-12-3 07:57
標題:
網頁登入-按鈕問題!
請各位大大幫我解決....
以下是我要登入的原始碼
以測試帳號密碼都輸入OK
問題一、 哪個是確定的按鈕 並且給我按下按鈕的語法
目前是設定
myWeb.Document.all("name='c_psd").Click
卻停在登入畫面 沒有按下確定的畫面 ((帳號密碼已輸入完畢))
<!-- IGNORE -->
<form action="" method="POST" name="">
<p> </P>
<table align=center id="default">
<tr>
<th colspan=2 class="center">請輸入登入資訊</th>
</tr>
<tr>
<td class="right">帳號:</td>
<td>
<input name="f_account" type="text" size="15" maxlength="10" value="" id="f_account">
</td>
</tr>
<tr>
<td class="right">密碼:</td>
<td>
<input name="f_psd" type="password" size="15" maxlength="10" value="" id="f_psd">
</td>
</tr>
<tr>
<td > </td>
<td>
<input type="submit" class="buttonsubmit" value=確定>
<input type="submit" class="buttonsubmit" value="修改密碼" onclick="c_psd()">
</td>
</tr>
</table>
<input type="hidden" name="f_step" id="f_step" value="from_default" />
<input type="hidden" name="f_c_psd" id="f_c_psd" value="false" />
</form>
複製代碼
作者:
GBKEE
時間:
2012-12-3 08:49
回復
1#
die78325
試試看
myWeb.Document.all("c_psd").Click
作者:
die78325
時間:
2012-12-3 10:08
本帖最後由 die78325 於 2012-12-3 10:10 編輯
回復
2#
GBKEE
大大 我上面打錯 我用的跟你用的一樣= ="!! 但是會錯誤 !
"c_psd()"
不知為何他會有()
依然停留在登入頁面卻沒按確定進去@@" 怪怪的= ="手動按就OK
還是因為我是用UserForm1.WebBrowser1來開啟網頁的關係= =?
我比較希望可以用IE來操作 但 改成IE的話 有些語法我不會改 變成他不會去偵測欄位
Dim IE As New InternetExplorer
sURL = "XXX"
Set IE = CreateObject("InternetExplorer.Application")
Set vDoc = IE.Document
((我會改成IE開啟 但到這一步就掛了 原本用 Set vDoc = myWeb.Document 可以)) <紅色為錯誤>
我另一個網站 打入帳號密碼 登入鍵部會亮((會灰色按鈕))
但是用鍵盤隨便輸入一個英文 就會亮了 所以他需要偵測鍵盤輸入才可以 那怎麼解決??
大大 不是我不PO檔案給你測試 是因為這是攸關公司配合的帳號密碼 不方便在此PO語法或檔案
作者:
GBKEE
時間:
2012-12-3 15:25
回復
3#
die78325
是攸關公司配合的帳號密碼 不方便在此PO語法或檔案
可參考看看
Option Explicit
Sub 麻辣家族討論版用戶登錄()
Dim IE As New InternetExplorer, i As Integer, vDoc As Object
'宣告 Dim ie As New InternetExplorer
'須在工具-> 設定引用項目加入 新增引用 Microsoft Internet Controls
'Dim i As Integer, vDoc As Object
'With CreateObject("InternetExplorer.Application") '不需新增引用 Microsoft Internet Controls
With IE
.Visible = True
.Navigate "http://forum.twbts.com/logging.php?action=login"
Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
Set vDoc = .Document.getElementsByTagName("INPUT")
For i = 0 To vDoc.Length - 1
If vDoc(i).Name = "username" Then vDoc(i).Value = "?????" '用戶名稱 請修改
If vDoc(i).Name = "password" Then vDoc(i).Value = "*******" '用戶密碼 請修改
Next
Set vDoc = .Document.getElementsByTagName("button") '.Click
For i = 0 To vDoc.Length - 1
If vDoc(i).Name = "loginsubmit" Then vDoc(i).Click
Next
Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
End With
End Sub
Sub 麻辣家族討論版用戶退出()
Dim i As Integer, vDoc As Object
With CreateObject("InternetExplorer.Application") '不需新增引用 Microsoft Internet Controls
.Visible = True
.Navigate "http://forum.twbts.com/logging.php?action=logout&formhash=053f893b"
.Quit '關閉網頁
End With
End Sub
複製代碼
作者:
die78325
時間:
2012-12-3 15:44
http://www.slc.com.tw/custom/gas/custom/index.php
大大 那這個網站幫我試試看 只要能按下去顯示帳號密碼錯誤就對了 @@"
因為我現在是連按都按不下去!@@
引用麻辣家族來修正
Option Explicit
Sub 麻辣家族討論版用戶登錄()
Dim IE As New InternetExplorer, i As Integer, vDoc As Object
'宣告 Dim ie As New InternetExplorer
'須在工具-> 設定引用項目加入 新增引用 Microsoft Internet Controls
'Dim i As Integer, vDoc As Object
'With CreateObject("InternetExplorer.Application") '不需新增引用 Microsoft Internet Controls
With IE
.Visible = True
.Navigate "http://www.slc.com.tw/custom/gas/custom/index.php"
Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
Set vDoc = .Document.getElementsByTagName("INPUT")
For i = 0 To vDoc.Length - 1
If vDoc(i).Name = "f_account" Then vDoc(i).Value = "8888" '用戶名稱 請修改
If vDoc(i).Name = "f_psd" Then vDoc(i).Value = "8888" '用戶密碼 請修改
Next
Set vDoc = .Document.getElementsByTagName("button") '.Click
For i = 0 To vDoc.Length - 1
If vDoc(i).Name = "c_psd" Then vDoc(i).Click
Next
Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
End With
End Sub
複製代碼
作者:
GBKEE
時間:
2012-12-3 16:14
本帖最後由 GBKEE 於 2012-12-3 16:16 編輯
回復
5#
die78325
每一網頁會有差異的.可從檢視原始檔案中看出端倪.
Option Explicit
Sub 用戶登錄()
' Dim IE As New InternetExplorer, i As Integer, vDoc As Object
'宣告 Dim ie As New InternetExplorer
'須在工具-> 設定引用項目加入 新增引用 Microsoft Internet Controls
Dim i As Integer, vDoc As Object
With CreateObject("InternetExplorer.Application") '不需新增引用 Microsoft Internet Controls
'With IE
.Visible = True
.Navigate "http://www.slc.com.tw/custom/gas/custom/index.php"
Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
Set vDoc = .Document.getElementsByTagName("INPUT")
For i = 0 To vDoc.Length - 1
If vDoc(i).Name = "f_account" Then vDoc(i).Value = "8888" '用戶名稱 請修改
If vDoc(i).Name = "f_psd" Then vDoc(i).Value = "8888" '用戶密碼 請修改
If vDoc(i).Value = "確定" Then vDoc(i).Click '用戶Click
Next
Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
End With
End Sub
複製代碼
作者:
die78325
時間:
2012-12-3 18:35
回復
6#
GBKEE
<input type="submit" class="buttonsubmit"
value=確定
>
<input type="submit" class="buttonsubmit" value="修改密碼" onclick="c_psd()">
大大 你怎麼知道要用value??
If vDoc(i).Name = "f_psd" Then vDoc(i).Value = "8888" '用戶密碼 請修改
If vDoc(i).Value = "確定" Then vDoc(i).Click '用戶Click
所以沒有 NAME就找其他的值嗎??
我又卡到了= =" 進到下一頁面 要找到欄位
輸入日期 20121201 到 20121202 ((網頁需求yyyymmdd))
但 他原始碼又沒有name
<!-- IGNORE -->
<input value="回查詢首頁" onclick="location.href='index.php'" type="button">
<form id="form1" name="form1" method="post" action="" onsubmit="return checkform()">
<table id="default2" align="center">
<tr>
<th class="center">請輸入查詢條件</th>
</tr>
<tr class="need">
<td>
時間格式:<input type="radio" name="date_format" id="date_format_td03" value="td03" ><label for="date_format_td03">交易日期</label>
<input type="radio" name="date_format" id="date_format_td16" value="td16" ><label for="date_format_td16">交班日期</label>
(<font color="blue">月-日/班島</font>)
</td>
</tr>
<tr class="need">
<td class=""><span id="red">*[必填]</span>時間:
<input name="f_dates" type="text" id="f_dates" size="10" maxlength="8" value="" />
~
<input name="f_datee" type="text" id="f_datee" size="10" maxlength="8" value="" />
(20090814∼20090814)
<input type="submit" name="button" id="button" value="送出" class="buttonsubmit" class="center"/>
有需要下載CSV檔案請打勾!<input type="checkbox" name="f_csv" >
比較會用到的舊以上這幾個
我只要輸入三樣
兩個日期欄位與送出 他有提供下載csv 如果可以 請幫我讓她點擊打勾
並送出
因為我直接在複製一次sub想說來改下一頁的資訊 還是不太行 =="
感謝大大協助....
作者:
GBKEE
時間:
2012-12-4 07:40
回復
7#
die78325
攸關這網頁安全,我也無法看到網頁替你修正
可參考這網頁的寫法
Sub 國際貨查詢()
Dim i As Integer, s As Integer, k As Integer, n, kn, j, xi
Dim Element, 統編 As String, ie As Object, sh As Worksheet
統編 = 16834268
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = True
.Navigate "http://public-cpd.mtnet.gov.tw/pub_newquery/query_national.asp"
Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
With .Document
Set Element = .getElementsByName("sel") '查詢類別
'0: 繳納單號
'1: 報單號碼
'2: 公司統編(身分證字號): "id"[公司統編] ,"sel01" [選項] , "portcode"[港別]
Element(2).Click '2: 公司統編(身分證字號)
Set Element = .getElementsByName("id") '[選項]
Element(0).Value = 統編
.getElementsByName("sel01")(0).Value = 2
'[選項]:<select name="sel01">
'value='1'>欠費清單 ' value='2' 所有繳納單
.getElementsByName("portcode")(0).Value = "TWKEL"
'[港別]: <select name="portcode">
'value='-'>所有港
'value='TWKEL' ->基隆港
'value='TWKHH' ->高雄港
'value='TWTXG' ->台中港
'value='TWHUN' ->花蓮港
'value='TWTPE' ->台北港
'value='TWSUO' ->蘇澳港
'value='TWANP' ->安平港
'value='TWBDA' ->布袋港
For i = 0 To .getelementsbytagname("INPUT").Length - 1 '尋找[開始查詢]按鍵
If .getelementsbytagname("INPUT")(i).Value = "開始查詢" Then
.getelementsbytagname("INPUT")(i).Click '按下 [開始查詢] 按鍵
Exit For
End If
Next
Do While ie.Busy Or ie.ReadyState <> 4: DoEvents: Loop
Set sh = ActiveSheet '指定工作表: 寫入資料
ActiveSheet.UsedRange.Offset(1).Clear
For i = 1 To .getelementsbytagname("table")(0).Rows.Length - 1 '寫入資料
k = k + 1
For j = 0 To 13
sh.Cells(k, j + 1) = .getelementsbytagname("table")(0).Rows(i).Cells(j).innertext
If i = .getelementsbytagname("table")(0).Rows.Length - 1 Then Exit For '最後一列顯示資料數
Next
Next
sh.Columns.AutoFit
End With
.Quit
End With
Set ie = Nothing
End Sub
複製代碼
***********
或可參考這做法
***********
作者:
sos29593691
時間:
2012-12-4 14:14
感謝大大們分享
作者:
die78325
時間:
2012-12-5 13:00
回復
8#
GBKEE
[attach]13392[/attach]
新問題 這網頁 他一定要偵測到鍵盤打字才有辦法開燈號 如何解決... 一樣測到帳號密碼錯誤即可!! 感謝大大!
作者:
GBKEE
時間:
2012-12-5 13:56
回復
10#
die78325
每一網頁的設計都不一樣
Option Explicit
Sub 用戶登錄()
' Dim IE As New InternetExplorer, i As Integer, vDoc As Object
'宣告 Dim ie As New InternetExplorer
'須在工具-> 設定引用項目加入 新增引用 Microsoft Internet Controls
Dim i As Integer, vDoc As Object
With CreateObject("InternetExplorer.Application") '不需新增引用 Microsoft Internet Controls
'With IE
.Visible = True 'IE顯示開關
Application.StatusBar = "正在登入系統,請稍後......"
.Navigate "http://car.plusgroup.com.tw:8080/corpdata_new/"
Do While .Busy Or .readyState <> 4: DoEvents: Loop
Set vDoc = .document.getelementsbytagname("INPUT")
For i = 0 To vDoc.Length - 1
If vDoc(i).Name = "rcptid" Then
vDoc(i).Value = "88888888" '統編輸入
Application.SendKeys ("~") '按下Enter 移到密碼框
ElseIf vDoc(i).Name = "password" Then
vDoc(i).Value = "66666666" '密碼輸入
Application.SendKeys ("~")
'統編,密碼 都有輸入,按下Enter後,此網頁自動檢查統編,密碼是否正確
'不用按[登 入]鍵
End If
Next
Do While .Busy Or .readyState <> 4: DoEvents: Loop
End With
Application.StatusBar = False
End Sub
複製代碼
作者:
die78325
時間:
2012-12-5 14:18
回復
11#
GBKEE
問題1.如果不顯示網站就沒辦法成功對嗎? 因為這方法我有想過 但 我想說會不會有別種方法可以達成不開網頁的部分
暫時先這樣來解決! 感謝大大
問題2.如果我要登入進去後 再換網址可以嗎? 因為進去之後要再按另一個按鈕 但按鈕按進去是不同網址 那我就想說是否可以直接轉址 就免去找按扭了
因為他的按鈕不適input
以下是原始碼
<body>
<div id="container">
<div id="header"> </div>
<div id="navcontainer">
<ul>
<li><a href="corpdata.jsp">逼逼</a></li>
<li><a href="carsdata.jsp">逼逼逼</a></li>
<li><a href="refueldata.jsp">逼逼逼逼</a></li>
<li><a href="logout.jsp"> 登 出 </a></li>
</ul>
或者大大可以提供我這樣怎麼去按jsp的語法...
作者:
GBKEE
時間:
2012-12-5 14:59
回復
12#
die78325
啊!網頁的設計.我涉獵不多,你的問題無法再進一步地替你解惑.
作者:
bugsfamily
時間:
2012-12-21 01:36
https://docs.google.com/document/pub?id=169oRI5TV0HWm0PySIzIIl9ngqS5oKVRxcdI6MqKdoBQ
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)