Maximus1 Posted December 22, 2010 Posted December 22, 2010 i`m trying to read some text from a website but it won`t work. cn you help me out please? #include <IE.au3> #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <String.au3> #include "C:\Dokumente und Einstellungen\t.nawrath\Desktop\autoit\install\Include\Array.au3" #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> $left = '* html body { margin-top: 0px; }' $right = '.sans { font-family: verdana,arial,helvetica,sans-serif; font-size: small; }' $oIE = _IECreateEmbedded () $gui = GUICreate("Embedded Internet Explorer", 1024, 850,(@DesktopWidth-1920)/2, (@DesktopHeight-1080)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) GUICtrlCreateObj($oIE, 10, 40 , 1000 , 700) $GUI_Button_Back = GuiCtrlCreateButton ("Back", 10, 800, 100, 30) $GUI_Button_Forward = GuiCtrlCreateButton ("Forward", 120, 800, 100, 30) $GUI_Button_Home = GuiCtrlCreateButton ("Home", 230, 800, 100, 30) $GUI_Button_Stop = GuiCtrlCreateButton ("Stop", 330, 800, 100, 30) $GUI_Button_ueber = GuiCtrlCreateButton ("Übertragen", 430, 800, 100, 30) GUISetState() _IENavigate ($oIE, "http://www.amazon.de") _IELoadWait ($oIE) BinaryToString($oIE) $source = _StringBetween($oIE, $left,$right) _ArrayDisplay($source,"test") ;does not show anything MsgBox(0,"",""& $source[0]) ;gives an error ==> Subscript used with non-Array variable.: MsgBox(0,"",""& $source[0]) MsgBox(0,"",""& $source^ ERROR Why and how to do it the right way?
wakillon Posted December 22, 2010 Posted December 22, 2010 (edited) Try _IENavigate ($oIE, "http://www.amazon.de") _IELoadWait ($oIE) $sHTML = _IEDocReadHTML ($oIE) ;ConsoleWrite ( "$sHTML : " & $sHTML & @Crlf ) $source = _StringBetween($sHTML, $left,$right) If Not @error Then _ArrayDisplay($source,"test") MsgBox(0,"",""& $source[0]) EndIf Edited December 22, 2010 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
Maximus1 Posted December 23, 2010 Author Posted December 23, 2010 (edited) hi, thanks it worked. after i added it to my script, it did not work anymore. :-( can you help me again please? in the following html code i wan`t to find "Steuerkuriosa seit Menschengedenken. Trostbilder für Steuerzahler aus fünf Jahrtausenden" <tr> <td class="cell"> <div class="tiny"> <strong> Titel</strong> </div> Steuerkuriosa seit Menschengedenken. Trostbilder für Steuerzahler aus fünf Jahrtausenden<p class="tiny"> <strong> the following will always present the error msgbox at Else. Global $left = '' Global $right = '<p class="tiny">' . . . . . . _IELoadWait ($oIE) $sHTML = _IEDocReadHTML ($oIE) ;ConsoleWrite ( "$sHTML : " & $sHTML & @Crlf ) $source = _StringBetween($sHTML, $left,$right) If Not @error Then _ArrayDisplay($source,"test") MsgBox(0,"",""& $source[0]) Else MsgBox(0,"","fehler nicht gefunden") EndIf Edited December 23, 2010 by Maximus1
ajag Posted December 23, 2010 Posted December 23, 2010 maximus1, this works for me #Include <Array.au3> #Include <String.au3> Local $Text = '<tr> <td class="cell"> <div class="tiny"> <strong> Titel</strong> </div>Steuerkuriosa seit Menschengedenken. Trostbilder für Steuerzahler aus fünf Jahrtausenden<p class="tiny"> <strong>' Global $left = '</div>' Global $right = '<p class="tiny">' $source = _StringBetween($Text, $left,$right) If Not @error Then _ArrayDisplay($source,"test") MsgBox(0,"",""& $source[0]) Else MsgBox(0,"","fehler nicht gefunden") EndIf A-Jay Rule #1: Always do a backup Rule #2: Always do a backup (backup of rule #1)
Maximus1 Posted December 23, 2010 Author Posted December 23, 2010 thanks :-) i had to change it a little bit. now i have a problem with linfeeds in the text. can you tell me how to eliminate them _IELoadWait ($oIE) $sText = _IEBodyReadText ($oIE) $source1 = _StringBetween($sText, $left1,$right1) If @error Then MsgBox(0,"","fehler nicht gefunden") EndIf $produkt = $source1[0]
ajag Posted December 24, 2010 Posted December 24, 2010 You could eliminate the linefeeds before cutting the string like $sText = StringReplace ( $sText, @LF, "" ) ; eliminates all linefeeds $sText = StringReplace ( $sText, @CR, "" ) ; eliminates all carriagereturn $sText = StringReplace ( $sText, @CRLF, "" ) ; eliminates all carriagereturn-linefeeds A-Jay Rule #1: Always do a backup Rule #2: Always do a backup (backup of rule #1)
Developers Jos Posted December 24, 2010 Developers Posted December 24, 2010 You could eliminate the linefeeds before cutting the string like $sText = StringReplace ( $sText, @LF, "" ) ; eliminates all linefeeds $sText = StringReplace ( $sText, @CR, "" ) ; eliminates all carriagereturn $sText = StringReplace ( $sText, @CRLF, "" ) ; eliminates all carriagereturn-linefeeds A-Jay Don't think you would need the @CRLF replace any more. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Maximus1 Posted December 24, 2010 Author Posted December 24, 2010 thanks to all of you. :-) my tool is ready now (i hope so).
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now