atzoref Posted February 14, 2012 Share Posted February 14, 2012 Hi, How can I read content (text for example) from exist HTML File? Thanks Link to comment Share on other sites More sharing options...
johnmcloud Posted February 14, 2012 Share Posted February 14, 2012 (edited) Use _StringBetween Example <p>some text</p> #include <String.au3> $file = @WorkingDir & "test.html" $test = _StringBetween($file, "<p>", "</p>") MsgBox(0,0, $test) Edited February 14, 2012 by johnmcloud Link to comment Share on other sites More sharing options...
Skitty Posted February 14, 2012 Share Posted February 14, 2012 (edited) You'll need for this.#include <Array.au3> #include "WinHttp.au3" $hOpen = _WinHttpOpen() $html = _GetSource("http://autorepo.tk/") ConsoleWrite($html & @CR) $Ret = StringRegExp($html,'(?s)(?i)<p>(.*?)</p>',3) _ArrayDisplay($Ret) Func _GetSource($URL) Local $aUrl = _WinHttpCrackUrl($url) If (UBound($aUrl) - 1) < 1 Then Return $hConnect = _WinHttpConnect($hOpen, $aUrl[2]) $hRequest = _WinHttpSimpleSendRequest($hConnect, Default, $aUrl[6]&$aUrl[7]) If $hRequest Then Local $html = _WinHttpSimpleReadData($hRequest) _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) Else _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) Return SetError(1,0,0) EndIf Return SetError(0,0,$html) EndFuncThe point is that regular expression can be used for this.$Ret = StringRegExp($html,'(?s)(?i)<p>(.*?)</p>',3) _ArrayDisplay($Ret) Edited February 14, 2012 by THAT1ANONYMOUSEDUDE Link to comment Share on other sites More sharing options...
somdcomputerguy Posted February 14, 2012 Share Posted February 14, 2012 Either of these two functions can be used also._INetGetSource_IEBodyReadText - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
atzoref Posted February 16, 2012 Author Share Posted February 16, 2012 It is not work for me. The situation is like this: The html include a table with one coloum of "Field" and second coloum of "Value" So I need to read a "Value" from the table by its "Field". How to do that. Link to comment Share on other sites More sharing options...
Skitty Posted February 16, 2012 Share Posted February 16, 2012 It is not work for me.The situation is like this:The html include a table with one coloum of "Field" and second coloum of "Value"So I need to read a "Value" from the table by its "Field".How to do that.Why not post an example of the html you're working with Link to comment Share on other sites More sharing options...
atzoref Posted February 16, 2012 Author Share Posted February 16, 2012 I found a nice way to open it in Notepad and then play with the string there. The problem is: how can I make a script which open the Html file with Notepad? so I can get the text from there and work on it... Link to comment Share on other sites More sharing options...
Skitty Posted February 16, 2012 Share Posted February 16, 2012 I found a nice way to open it in Notepad and then play with the string there. The problem is: how can I make a script which open the Html file with Notepad? so I can get the text from there and work on it... There are many ways $file = FileOpenDialog("Select file","","All(*.*)",1) Run("NotePad "&$file) Sleep(500) Local $text = WinGetText("[CLASS:Notepad]", "") MsgBox(0, "Text read was:", $text) Link to comment Share on other sites More sharing options...
atzoref Posted February 20, 2012 Author Share Posted February 20, 2012 Thanks, it works. But the "Open dialog" still wait for me to press on the "Open" button, and I want it to do the "Open" process automatic after choosing the file I try to use "ControlClick" with this dialog but it no work because it is stuch on the "Open Dialog" Process. How can I solve this? Link to comment Share on other sites More sharing options...
somdcomputerguy Posted February 20, 2012 Share Posted February 20, 2012 It is not work for me.The situation is like this:The html include a table with one coloum of "Field" and second coloum of "Value"So I need to read a "Value" from the table by its "Field".How to do that.Function _IETableWriteToArray - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
atzoref Posted February 20, 2012 Author Share Posted February 20, 2012 Thanks I will try it too, But someone can give me an answer on my question in my last post? Link to comment Share on other sites More sharing options...
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