Jump to content

Recommended Posts

Posted (edited)

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
Posted

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

 

Posted
  On 10/14/2016 at 6:18 AM, 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

 

Expand  

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

Posted
  On 10/14/2016 at 12:34 PM, l3ill said:

???

you should get 5 consecutive msgbox's with the 5 dates.

is that not happening?

Expand  

Yes there is nothing , and i notice now where there is not something like this in your code:
 

$oLinks = _IETagNameGetCollection($oIE, "input")

 

Posted (edited)

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.

  On 10/14/2016 at 4:43 AM, abdulrahmanok said:

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

Expand  

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

 

Edited by AutoBert
Posted
  On 10/14/2016 at 12:40 PM, 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

Expand  

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

do you mean replace  $sText=FileRead by _IEBodyReadHTML?

Posted

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

Posted

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

Posted
  On 10/14/2016 at 1:59 PM, 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.txtFetching info...

Expand  

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]

Posted

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

     

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
  • Recently Browsing   0 members

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