找回密码
 加入
搜索
查看: 1817|回复: 2

GUI介面抓不同網頁數值依序寫入

[复制链接]
发表于 2009-2-26 13:43:39 | 显示全部楼层 |阅读模式
想請問我程式在31~51行的For Next迴圈中,我設計要依序讀出不同網頁的數值,然後依序填入,不過寫出來只會讀到第一個網頁然後顯示第一列資料而已,不會讀第二個網頁顯示第二列資料,一直循環下去,該如何修正呢?

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <IE.au3>
#include <Array.au3>

Dim $oInput[10][10]
Dim $Address[10]
Dim $ImageAddress[10]
Dim $ListView[10]
Dim $j

$Address[0]="B15,072";查詢代碼
$Address[1]="B09,001"

$ImageAddress[0]="http://allsharing.net/drupal_5_1/lineworld/fund/html/0549.htm"
$ImageAddress[1]="http://allsharing.net/drupal_5_1/lineworld/fund/html/BLKMEMAA.htm"

#Region ### START Koda GUI section ### Form=D:\AutoIt\腳本\tabbed pages.kxf
$dlgTabbed = GUICreate("Tabbed Notebook Dialog", 500, 298, 261, 182);寬 高 左側 上方
GUISetIcon("D:\005.ico")
$PageControl1 = GUICtrlCreateTab(8, 8, 396, 256)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)

$TabSheet1 = GUICtrlCreateTabItem("Funds")
$ListView1 = GUICtrlCreateListView("Item|Date|Name|Address|Value", 8,26,400,240);左側 上方 寬 高

;讀取網頁表格數據
For $j=0 To $j=1

$oIE2 = _IECreate ("http://fund.cnyes.com/fund_nav.asp?fundcode=" & $Address[$j],0,0,1,0);不顯示IE 0 0 1 0
$oInputs = _IETableGetCollection ($oIE2) ;返回指網頁內所有表格的目標變量
$iNumTables = @extended ;文檔內所以表格的數量
$i = 14;指定顯示第幾個表格欄位 $i+1個
$table = _IETableGetCollection ($oIE2,$i)
$oInput = _IETableWriteToArray ($table) ;讀取指定表格內的數據,寫入到數組
;

;讀入全部資料
;For $i=0 To UBound($oInput,2)-1             ;行
        ;Dim $lv_item=""
        ;For $j=UBound($oInput,1)-1 To 0 Step -1  ;列
                ;$lv_item=$oInput[$j][1]&"|"&$lv_item        
        ;Next        
        ;GUICtrlCreateListViewItem($lv_item,$ListView1)        
;Next        

$ListView[$j] = GUICtrlCreateListViewItem($j&"|"&$oInput[1][1]&"|"&$oInput[1][0]&"|"&$oInput[3][0]&"|"&$oInput[1][3], $ListView1)
Next

GUICtrlSetState(-1,$GUI_SHOW); will be display first
$TabSheet3 = GUICtrlCreateTabItem("Image")

;嵌入圖片
$oIE_code = _IECreateEmbedded ()
$GUIActiveX = GUICtrlCreateObj($oIE_code, 8,25,396,250);定義內嵌IE 窗口大小
;嵌入圖片 結束

$TabSheet2 = GUICtrlCreateTabItem("IE TAB")

;嵌入IE在分頁上
$oIE = _IECreateEmbedded ();Create a Webbrowser object suitable for embedding in an AutoIt GUI with GuiCtrlCreateObj().
$GUIActiveX = GUICtrlCreateObj($oIE, 8,25,396,250);定義內嵌IE 窗口大小
;嵌入IE在分頁上 結束


GUICtrlCreateTabItem(""); end tabitem definition
$Button0 = GUICtrlCreateButton("&GetImage0", 420, 46, 65, 20, 0);左側 上方 按鈕寬度 按鈕高度?
$Button1 = GUICtrlCreateButton("&GetImage1", 420, 70, 65, 20, 0);左側 上方 按鈕寬度 按鈕高度
$Button2 = GUICtrlCreateButton("&OK", 166, 272, 75, 25, 0)
$Button3 = GUICtrlCreateButton("&Cancel", 246, 272, 75, 25, 0)
$Button4 = GUICtrlCreateButton("&Help", 328, 272, 75, 25, 0)


GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        Case $Button0
                        Get_fakeimage()
                        ;嵌入IE在分頁上
            _IENavigate ($oIE, $ImageAddress[0]);將IE指向URL
            ;嵌入IE在分頁上 結束
            Get_image()
        Case $Button1
                        Get_fakeimage()
                        ;嵌入IE在分頁上
            _IENavigate ($oIE, $ImageAddress[1]);將IE指向URL
            ;嵌入IE在分頁上 結束
            Get_image()                                
        EndSwitch
WEnd

Func Get_fakeimage()
;嵌入圖片
_IENavigate ($oIE_code, "about:blank",1)
;加載一個空白網頁,可以自定一個網頁,讓驗證碼圖片顯示左左對齊,頂部對齊,如果你會HTML應該明白什麼意思
$oBody = _IETagNameGetCollection($oIE_code, "body", 0)
_IEDocInsertHTML($oBody, 'IE加載中...', "afterbegin");在嵌入IE底部追加文字
;嵌入圖片 結束
EndFunc
Func Get_IE()
;嵌入IE在分頁上
_IENavigate ($oIE, $ImageAddress[0]);將IE指向URL
;嵌入IE在分頁上 結束
EndFunc
Func Get_image()
$oImg = _IEImgGetCollection ($oIE,0);返回IE文檔內IMG
$oPic = $oIE.Document.body.createControlRange()
$oPic.Add($oImg)
$oPic.execCommand("Copy");複製到剪貼板
$ImageFilePath = ClipGet();獲取路徑,在臨時文件裡面
 _IEAction ( $oIE_code,"refresh" );刷新嵌入IE頁面
$oBody = _IETagNameGetCollection($oIE_code, "body", 0)
_IEDocInsertHTML($oBody, '<img src='& FileGetShortName($ImageFilePath) &'>', "afterbegin");在嵌入IE底部追加圖片顯示
EndFunc


[ 本帖最后由 fancky 于 2009-2-26 14:27 编辑 ]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2009-2-26 14:22:31 | 显示全部楼层
for $j=0 to 1
 楼主| 发表于 2009-2-26 14:27:04 | 显示全部楼层
原來我是這個小地方沒注意到,太慚愧了,感謝您的幫忙
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-19 02:09 , Processed in 0.085000 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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