Jump to content

Putting HTML into an array


Recommended Posts

I believe in html a new line is created through </ br> or <br>

did you check the source of the html page?

(I could be wrong, this is an assumption)

That's not precisely what i meant. I can grab the html like this:

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("GET","http://www.autoitscript.com/forum/index.php")
$oHTTP.Send()
$HTMLSource = $oHTTP.Responsetext

and it's all dumped into a big string. If you execute this you will see that practically none of the lines end in </br>.

I want each line in that string to be an index in my array.

Link to comment
Share on other sites

let me see if I understand you correctly. If you want to put that HTML into an array you need to write 1 line after another, but the code you used grabs the Whole HTML at once & inserts it all in the first line of the array.

I had same problem, but the only solution I was able to find was this: & then i use filereadline to put lines into the array

#include <INet.au3>
$a = _INetGetSource('www.autoitscript.com')

$file = FileOpen("test.txt", 1)

; Check if file opened for writing OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

FileWrite($file,$a  & @CRLF)

FileClose($file)

But all this is hyper mega slow, so if i need to check around 500 sources it will take a while.

A side note, dont use arrays unless you can do it with:

$StringInStr(FileReadLine($file,150), "RING")

Is there a way to use ConsoleWrite(_INetGetSource('www.autoitscript.com')) & then read those lines from console 1 by 1 or search for a lines with sertain text ? like Consloereadline?

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
Share on other sites

Try this:

#include <Array.au3>

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("GET","http://www.autoitscript.com/forum/index.php")
$oHTTP.Send()
$HTMLSource = $oHTTP.Responsetext

$aSource = StringSplit($HTMLSource, @LF)

_ArrayDisplay($aSource)

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

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