Jump to content
Sign in to follow this  
MaoMao

Simple research program search help

Recommended Posts

MaoMao

New in testing a research program for download log.

The process is to search the number of Downloads for the program names in the txt file.

Result can be displayed in IE new tab page and write to excel file.

Can anyone help the following problem.

1) How to identify and What is the search keywork object name in the http://sourceforge.net page?

2) What is the "Download log" result object name in the source page?

3) Is the Excel program correct in setting and writing the file?

; Separate Text file LogNames.txt

LogNames.txt

Firefox

Chrome

Internet Explorer

Safari

Opera

#include <File.au3>
$file = FileOpen(@WorkingDir&"\LogNames.txt", 0)
; Check if file opened for reading OK
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf
#include <IE.au3>
#include <Excel.au3>
Local $oExcel = _ExcelBookNew() ;Create new book, make it visible
$ROW = 0
$COL = 0
$oIE = _IECreate ("http://sourceforge.net", 0, 0)
; Read in lines of text until the EOF is reached
While 1
$LogLine = FileReadLine($file)
If @error = -1 Then ExitLoop

$ROW = $ROW + 1

  $LogCode = StringMid ($LogLine, 1, 20); Extract LogCode

$oIET1 = __IENavigate($oIE, "http://sourceforge.net", 1, 2048)

$oForm = _IEFormGetObjByName ($oIET1, "mainform")
$oText = _IEFormElementGetObjByName ($oForm, "EnterSearch?_Name")
_IEFormElementSetValue($oText, $LogCode)
$oQuery = _IEFormElementGetObjByName ($oForm, "q")
_IEFormSubmit ($oForm)
    ; ERROR IN Display the innerText on an element on the page with a name of "download"
     $oMarquee = _IEGetObjByName ($oIET1, "DOWNLOAD")
     MsgBox(0, "SourceForge Information T1", $oMarquee)

; WRITE TO EXCEL FILE testing code
;Declare the Array
Local $aArray[$ROW][2] = [[$LogCode, $oMarquee]]
_ExcelWriteSheetFromArray($oExcel, $aArray, 1, 1, 0, 0) ;0-Base Array parameters
;  Need to edit and verify

Wend; end of While
SoundPlay("C:\Windows\media\chimes.wav",1)
MsgBox(4096,"Done!","All Log data files have been created!")

MsgBox(0, "Exiting", "Press OK to Save File and Exit")
_ExcelBookSaveAs($oExcel, @TempDir & "\EXCELTemp.xls", "xls", 0, 1) ; Now we save it into the temp directory; overwrite existing file if necessary
_ExcelBookClose($oExcel) ; And finally we close out

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.