返回列表 上一主題 發帖

[發問] 網頁登入-按鈕問題!

[發問] 網頁登入-按鈕問題!

請各位大大幫我解決....
以下是我要登入的原始碼
以測試帳號密碼都輸入OK
問題一、 哪個是確定的按鈕  並且給我按下按鈕的語法
目前是設定   myWeb.Document.all("name='c_psd").Click
卻停在登入畫面 沒有按下確定的畫面 ((帳號密碼已輸入完畢))
  1. <!-- IGNORE -->

  2. <form action="" method="POST" name="">
  3. <p>&nbsp;</P>
  4. <table align=center id="default">
  5.     <tr>
  6.       <th colspan=2 class="center">請輸入登入資訊</th>
  7.     </tr>
  8.     <tr>
  9.       <td class="right">帳號:</td>
  10.       <td>
  11.       <input name="f_account" type="text" size="15" maxlength="10" value="" id="f_account">
  12.       </td>
  13.     </tr>
  14.     <tr>
  15.       <td class="right">密碼:</td>
  16.       <td>
  17.       <input name="f_psd" type="password" size="15" maxlength="10" value="" id="f_psd">
  18.       </td>
  19.     </tr>
  20.     <tr>
  21.       <td >&nbsp;</td>
  22.       <td>
  23.         <input type="submit" class="buttonsubmit" value=確定>
  24.           <input type="submit" class="buttonsubmit" value="修改密碼" onclick="c_psd()">
  25.       </td>
  26.     </tr>
  27.   </table>
  28.   <input type="hidden" name="f_step" id="f_step" value="from_default" />
  29.   <input type="hidden" name="f_c_psd" id="f_c_psd" value="false" />
  30. </form>
複製代碼
自用車也可以簽帳喔!
五千元加油金加入油箱後還回饋您6200元
福利旺車友會power-want.com

回復 1# die78325
試試看
myWeb.Document.all("c_psd").Click

TOP

本帖最後由 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語法或檔案
自用車也可以簽帳喔!
五千元加油金加入油箱後還回饋您6200元
福利旺車友會power-want.com

TOP

回復 3# die78325
是攸關公司配合的帳號密碼  不方便在此PO語法或檔案
可參考看看
  1. Option Explicit
  2. Sub 麻辣家族討論版用戶登錄()
  3.    Dim IE As New InternetExplorer, i As Integer, vDoc As Object
  4.     '宣告 Dim ie As New InternetExplorer
  5.     '須在工具-> 設定引用項目加入 新增引用 Microsoft Internet Controls
  6.     'Dim i As Integer, vDoc As Object
  7.     'With CreateObject("InternetExplorer.Application") '不需新增引用 Microsoft Internet Controls
  8.     With IE
  9.         .Visible = True
  10.         .Navigate "http://forum.twbts.com/logging.php?action=login"
  11.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  12.         Set vDoc = .Document.getElementsByTagName("INPUT")
  13.         For i = 0 To vDoc.Length - 1
  14.             If vDoc(i).Name = "username" Then vDoc(i).Value = "?????"    '用戶名稱 請修改
  15.             If vDoc(i).Name = "password" Then vDoc(i).Value = "*******"  '用戶密碼 請修改
  16.         Next
  17.         Set vDoc = .Document.getElementsByTagName("button") '.Click
  18.         For i = 0 To vDoc.Length - 1
  19.             If vDoc(i).Name = "loginsubmit" Then vDoc(i).Click
  20.         Next
  21.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  22.     End With
  23. End Sub
  24. Sub 麻辣家族討論版用戶退出()
  25. Dim i As Integer, vDoc As Object
  26.      With CreateObject("InternetExplorer.Application") '不需新增引用 Microsoft Internet Controls
  27.         .Visible = True
  28.         .Navigate "http://forum.twbts.com/logging.php?action=logout&formhash=053f893b"
  29.         .Quit           '關閉網頁
  30.     End With
  31. End Sub
複製代碼

TOP

http://www.slc.com.tw/custom/gas/custom/index.php
大大 那這個網站幫我試試看 只要能按下去顯示帳號密碼錯誤就對了 @@"
因為我現在是連按都按不下去!@@
引用麻辣家族來修正
  1. Option Explicit
  2. Sub 麻辣家族討論版用戶登錄()
  3.    Dim IE As New InternetExplorer, i As Integer, vDoc As Object
  4.     '宣告 Dim ie As New InternetExplorer
  5.     '須在工具-> 設定引用項目加入 新增引用 Microsoft Internet Controls
  6.     'Dim i As Integer, vDoc As Object
  7.     'With CreateObject("InternetExplorer.Application") '不需新增引用 Microsoft Internet Controls
  8.     With IE
  9.         .Visible = True
  10.         .Navigate "http://www.slc.com.tw/custom/gas/custom/index.php"
  11.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  12.         Set vDoc = .Document.getElementsByTagName("INPUT")
  13.         For i = 0 To vDoc.Length - 1
  14.             If vDoc(i).Name = "f_account" Then vDoc(i).Value = "8888"    '用戶名稱 請修改
  15.             If vDoc(i).Name = "f_psd" Then vDoc(i).Value = "8888"  '用戶密碼 請修改
  16.         Next
  17.         Set vDoc = .Document.getElementsByTagName("button") '.Click
  18.         For i = 0 To vDoc.Length - 1
  19.             If vDoc(i).Name = "c_psd" Then vDoc(i).Click
  20.         Next
  21.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  22.     End With
  23. End Sub
複製代碼
自用車也可以簽帳喔!
五千元加油金加入油箱後還回饋您6200元
福利旺車友會power-want.com

TOP

本帖最後由 GBKEE 於 2012-12-3 16:16 編輯

回復 5# die78325
每一網頁會有差異的.可從檢視原始檔案中看出端倪.
  1. Option Explicit
  2. Sub 用戶登錄()
  3. '  Dim IE As New InternetExplorer, i As Integer, vDoc As Object
  4.     '宣告 Dim ie As New InternetExplorer
  5.     '須在工具-> 設定引用項目加入 新增引用 Microsoft Internet Controls
  6.     Dim i As Integer, vDoc As Object
  7.     With CreateObject("InternetExplorer.Application") '不需新增引用 Microsoft Internet Controls
  8.     'With IE
  9.         .Visible = True
  10.         .Navigate "http://www.slc.com.tw/custom/gas/custom/index.php"
  11.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  12.         Set vDoc = .Document.getElementsByTagName("INPUT")
  13.         For i = 0 To vDoc.Length - 1
  14.             If vDoc(i).Name = "f_account" Then vDoc(i).Value = "8888"    '用戶名稱 請修改
  15.             If vDoc(i).Name = "f_psd" Then vDoc(i).Value = "8888"  '用戶密碼 請修改
  16.             If vDoc(i).Value = "確定" Then vDoc(i).Click           '用戶Click
  17.         Next
  18.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  19.     End With
  20. End Sub
複製代碼

TOP

回復 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想說來改下一頁的資訊 還是不太行 =="
感謝大大協助....
自用車也可以簽帳喔!
五千元加油金加入油箱後還回饋您6200元
福利旺車友會power-want.com

TOP

回復 7# die78325
攸關這網頁安全,我也無法看到網頁替你修正
可參考這網頁的寫法
  1. Sub 國際貨查詢()
  2.     Dim i As Integer, s As Integer, k As Integer, n, kn, j, xi
  3.     Dim Element, 統編 As String, ie As Object, sh As Worksheet
  4.         統編 = 16834268
  5.     Set ie = CreateObject("InternetExplorer.Application")
  6.     With ie
  7.         .Visible = True
  8.         .Navigate "http://public-cpd.mtnet.gov.tw/pub_newquery/query_national.asp"
  9.         Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
  10.         With .Document
  11.             Set Element = .getElementsByName("sel")  '查詢類別
  12.             '0: 繳納單號
  13.             '1: 報單號碼
  14.             '2: 公司統編(身分證字號):  "id"[公司統編] ,"sel01" [選項] , "portcode"[港別]
  15.             Element(2).Click  '2: 公司統編(身分證字號)
  16.             Set Element = .getElementsByName("id") '[選項]
  17.             Element(0).Value = 統編
  18.             .getElementsByName("sel01")(0).Value = 2
  19.             '[選項]:<select name="sel01">
  20.              'value='1'>欠費清單 ' value='2' 所有繳納單
  21.             .getElementsByName("portcode")(0).Value = "TWKEL"
  22.             '[港別]: <select name="portcode">
  23.              'value='-'>所有港
  24.              'value='TWKEL' ->基隆港
  25.              'value='TWKHH' ->高雄港
  26.              'value='TWTXG' ->台中港
  27.              'value='TWHUN' ->花蓮港
  28.              'value='TWTPE' ->台北港
  29.              'value='TWSUO' ->蘇澳港
  30.              'value='TWANP' ->安平港
  31.              'value='TWBDA' ->布袋港
  32.             For i = 0 To .getelementsbytagname("INPUT").Length - 1              '尋找[開始查詢]按鍵
  33.                 If .getelementsbytagname("INPUT")(i).Value = "開始查詢" Then
  34.                     .getelementsbytagname("INPUT")(i).Click                     '按下 [開始查詢] 按鍵
  35.                     Exit For
  36.                 End If
  37.             Next
  38.             Do While ie.Busy Or ie.ReadyState <> 4: DoEvents: Loop
  39.             Set sh = ActiveSheet                                                '指定工作表: 寫入資料
  40.             ActiveSheet.UsedRange.Offset(1).Clear
  41.             For i = 1 To .getelementsbytagname("table")(0).Rows.Length - 1      '寫入資料
  42.                 k = k + 1
  43.                 For j = 0 To 13
  44.                     sh.Cells(k, j + 1) = .getelementsbytagname("table")(0).Rows(i).Cells(j).innertext
  45.                     If i = .getelementsbytagname("table")(0).Rows.Length - 1 Then Exit For   '最後一列顯示資料數
  46.                 Next
  47.             Next
  48.             sh.Columns.AutoFit
  49.         End With
  50.                .Quit
  51.     End With
  52.     Set ie = Nothing        
  53. End Sub
複製代碼
***********
或可參考這做法
***********

TOP

感謝大大們分享

TOP

回復 8# GBKEE


    灰色按鈕登入問題.rar (14.76 KB)

新問題 這網頁 他一定要偵測到鍵盤打字才有辦法開燈號  如何解決...  一樣測到帳號密碼錯誤即可!! 感謝大大!
自用車也可以簽帳喔!
五千元加油金加入油箱後還回饋您6200元
福利旺車友會power-want.com

TOP

        靜思自在 : 我們要做好社會的環保,也要做好內心的環保。
返回列表 上一主題