Jump to content

Reading from HTML File


atzoref
 Share

Recommended Posts

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

Link to comment
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)
Link to comment
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?

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

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