Sign in to follow this  
Followers 0
atzoref

Reading from HTML File

11 posts in this topic

Hi,

How can I read content (text for example) from exist HTML File?

Thanks

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by johnmcloud

Share this post


Link to post
Share on other sites

#3 ·  Posted (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)
EndFunc

The point is that regular expression can be used for this.

$Ret = StringRegExp($html,'(?s)(?i)<p>(.*?)</p>',3)
_ArrayDisplay($Ret)
Edited by THAT1ANONYMOUSEDUDE

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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


Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

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...

Share this post


Link to post
Share on other sites

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)

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Thanks I will try it too,

But someone can give me an answer on my question in my last post?

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  
Followers 0