Jump to content

Read Date From menu


Recommended Posts

Hi Brothers Thank you all for your efforts I have this data :

 
<TR>
<TD CLASS="dddefault">
<SELECT NAME="selected_day">
<OPTION VALUE="14-OCT-16">14-OCT-16
<OPTION VALUE="13-OCT-16">13-OCT-16
<OPTION VALUE="12-OCT-16">12-OCT-16
<OPTION VALUE="11-OCT-16">11-OCT-16
<OPTION VALUE="10-OCT-16">10-OCT-16
</SELECT>
</TR>

I want to Get "Selected day " values into Variables and write it to msgbox or txt file

for example :

Value 1 = selected day,1

Because the date changes every day so i can't expect witch text written in 

Solved :

Ty All Brothers

Edited by abdulrahmanok
Link to comment
Share on other sites

Or this one:

Local $sFilePath = @ScriptDir & "\test.txt"


; Read the current script file into an array using the filepath.
Local $aArray = FileReadToArray($sFilePath)
If @error Then
    MsgBox(0, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file.
Else
    For $i = 0 To UBound($aArray) - 1 ; Loop through the array.
        $iString = StringInStr($aArray[$i], "OPTION VALUE")
        If $iString > 1 Then
            $sMyString = StringMid($aArray[$i], 16, 9)
            MsgBox(0, "My String", $sMyString)
        Else
            ContinueLoop
        EndIf
    Next
EndIf

 

Link to comment
Share on other sites

5 hours ago, l3ill said:

Or this one:

Local $sFilePath = @ScriptDir & "\test.txt"


; Read the current script file into an array using the filepath.
Local $aArray = FileReadToArray($sFilePath)
If @error Then
    MsgBox(0, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file.
Else
    For $i = 0 To UBound($aArray) - 1 ; Loop through the array.
        $iString = StringInStr($aArray[$i], "OPTION VALUE")
        If $iString > 1 Then
            $sMyString = StringMid($aArray[$i], 16, 9)
            MsgBox(0, "My String", $sMyString)
        Else
            ContinueLoop
        EndIf
    Next
EndIf

 

didn't show error and also didn't show msgbox or edit text

Link to comment
Share on other sites

You could also try this:

#Include <Array.au3>
#Include <String.au3>
$sText=FileRead('IE_Snipet.txt')    ;replace this with _IEBodyReadHTML
$aDate=_StringBetween($sText,'<SELECT NAME="selected_day">','</SELECT>')
If IsArray($aDate) Then $aDate=_StringBetween($aDate[0],'OPTION VALUE="','">')
If IsArray($aDate) Then
    _ArrayDisplay($aDate)
Else
    ConsoleWrite('Nothing found')
EndIf

Text is data from your opening post.

But it isn't realy needed to do it this way.

8 hours ago, abdulrahmanok said:

Because the date changes every day so i can't expect witch text written in 

If the first option is always today you can also calculate the other options with _DateAdd and some stringmanipulations.

 

Edited by AutoBert
Link to comment
Share on other sites

39 minutes ago, AutoBert said:

#Include <Array.au3> #Include <String.au3> $sText=FileRead('IE_Snipet.txt') ;replace this with _IEBodyReadHTML $aDate=_StringBetween($sText,'<SELECT NAME="selected_day">','</SELECT>') If IsArray($aDate) Then $aDate=_StringBetween($aDate[0],'OPTION VALUE="','">') If IsArray($aDate) Then _ArrayDisplay($aDate) Else ConsoleWrite('Nothing found') EndIf

;replace this with _IEBodyReadHTML  Sorry for noob question but how to do this ?

do you mean replace  $sText=FileRead by _IEBodyReadHTML?

Link to comment
Share on other sites

Its stuck again in code and didn't show any result this is full code please check it 
 

Local $aArray = FileReadToArray($sFilePath)
If @error Then
    MsgBox(0, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file.
Else
    For $i = 0 To UBound($aArray) - 1 ; Loop through the array.
        $iString = StringInStr($aArray[$i], "OPTION VALUE")
        If $iString > 1 Then
            $sMyString = StringMid($aArray[$i], 16, 9)
            MsgBox(0, "My String", $sMyString)
        Else
            ContinueLoop
        EndIf
    Next
EndIf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Your Code :

$sText=_IEBodyReadHTML($oIE)    ;replace this with _IEBodyReadHTML
$aDate=_StringBetween($sText,'<SELECT NAME="selected_day">','</SELECT>')
If IsArray($aDate) Then $aDate=_StringBetween($aDate[0],'OPTION VALUE="','">')
If IsArray($aDate) Then
    _ArrayDisplay($aDate)
Else
    ConsoleWrite('Nothing found')
EndIf

MsgBox(0,"Passed","Continue")

I created msg box to check but i cant even see "Passed","Continue"

that's mean debug stuck in previous code

Link to comment
Share on other sites

You are mixing 2 difernetly ways to solve. If you would try my solution, than

  1. run script as i posted in https://www.autoitscript.com/forum/topic/185030-read-date-from-menu/?do=findComment&comment=1328997  using IE_Snipet.txt
  2. After change my script replacing line 3 with this 2 lines:
    $oIE=_IECreate('YourUrl')   ;change to your real URL
    $sText=_IEBodyReadHTML($oIE)

    and run again.  In both cases you get a array with the dates: 

  3. 107_ArrayDisplay.jpg

IE_Snipet.txt

Link to comment
Share on other sites

5 hours ago, AutoBert said:

You are mixing 2 difernetly ways to solve. If you would try my solution, than

  1. run script as i posted in https://www.autoitscript.com/forum/topic/185030-read-date-from-menu/?do=findComment&comment=1328997  using IE_Snipet.txt
  2. After change my script replacing line 3 with this 2 lines:
    $oIE=_IECreate('YourUrl')   ;change to your real URL
    $sText=_IEBodyReadHTML($oIE)

    and run again.  In both cases you get a array with the dates: 

  3. 107_ArrayDisplay.jpg

IE_Snipet.txt

Tyyy Finally its worked i was need to Add (sleep) before your code to wait page until loading
I have final request if you can , I need to set this variables in text for example :

text lane 1 = [row0]

text lane2 = [row1]

Link to comment
Share on other sites

Thank You All Brothers little search and i found the code this is full code :
#Include <Array.au3>
#Include <String.au3>
#include <file.au3>
 

$sText=_IEBodyReadHTML($oIE)
$aDate=_StringBetween($sText,'<SELECT NAME="selected_day">','</SELECT>')
If IsArray($aDate) Then $aDate=_StringBetween($aDate[0],'OPTION VALUE="','">')
If IsArray($aDate) Then
    _ArrayDisplay($aDate)
    MsgBox(0,"",$aDate[0])
    MsgBox(0,"",$aDate[1])
        MsgBox(0,"",$aDate[2])
            MsgBox(0,"",$aDate[3])
MsgBox(0,"",$aDate[4])

Else
    ConsoleWrite('Nothing found')
EndIf

Special Thanks To @AutoBert

     

Link to comment
Share on other sites

32 minutes ago, AutoBert said:

extend script with

For $i=0 To UBound($aDate) -1 
    MsgBox(0,$i&':',$aDate[$i]
Next

and you will see how to output specific element of the array. I suggest also reading wiki about Arrays .

Ty Again I Appreciate to you , I'm started to understand Arrays now a bit and I'm trying to read about

it more .

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...