Jump to content

Recommended Posts

Posted (edited)

Hi guys,

imagine: i get this source code (Html) from a website, this is written into a txtfile.

<TABLE cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR height=30>
<TD width=450><B>Text</B></TD>
<TD width=100><B>date</B></TD>
<TD width=50><B>rating</B></TD></TR>
<TR>
<TD><A href="http://localhost/~ OSS ~ /program1.zip">Program 1</A></TD>
<TD>2004-12-02</TD>
<TD>22%</TD></TR>
<TR>
<TD><A href="http://localhost/~ OSS ~ /program2.zip">Program 2</A></TD>
<TD>2005-01-03</TD>
<TD>17%</TD></TR>
<TR>
<TD><A href="http://localhost/~ OSS ~ /test.zip">Program B</A></TD>
<TD>2005-01-03</TD>
<TD>17%</TD></TR>
</TBODY></TABLE>

How can i the link in variable $link[0] and the Program name in variable $name[0] etc.?

So it would go like this:

$link[0] = 'http://localhost/~ OSS ~ /program1.zip'

$link[1] = 'http://localhost/~ OSS ~ /program2.zip'

$link[2] = 'http://localhost/~ OSS ~ /test.zip'

$name[0] = 'Program 1'

$name[1] = 'Program 2'

$name[1] = 'Program B'

I know i have to do it with StringRegExp etc., but i don't know how to make it work :D

Just too noob for that :P

I've checked the helpfile :D

I'm using the latest beta of autoit..

Can anyone help me to understand how to do it?

Edited by Noobster24
Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.
Posted (edited)

@neogia has a nice tutorial.

You might want to do a search for StringRegExp with negoia in the "filter by member name" field and tick of the "match exact name"

Edited by Uten
  • Moderators
Posted

Here, I tested this on your example text

$FilePath = @ScriptDir & '\ParseTest.txt'
$Links = _SRE_Between($FilePath, '<TD><A href="', '">')
$Names = _SRE_Between($FilePath, '">', '</A></TD>')

If IsArray($Links) And IsArray($Names) Then
    For $i = 0 To UBound($Links) - 1
        MsgBox(0, $Names[$i], $Links[$i])
    Next
EndIf

Func _SRE_Between($s_FilePath, $s_Start, $s_End)
    $h_FRead = FileRead($s_FilePath, FileGetSize($s_FilePath))
    $a_Array = StringRegExp($h_FRead, '(?:' & $s_Start & ')(.*?)(?:' & $s_End & ')', 3)
    If Not @error Then Return $a_Array
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

Here, I tested this on your example text

$FilePath = @ScriptDir & '\ParseTest.txt'
$Links = _SRE_Between($FilePath, '<TD><A href="', '">')
$Names = _SRE_Between($FilePath, '">', '</A></TD>')

If IsArray($Links) And IsArray($Names) Then
    For $i = 0 To UBound($Links) - 1
        MsgBox(0, $Names[$i], $Links[$i])
    Next
EndIf

Func _SRE_Between($s_FilePath, $s_Start, $s_End)
    $h_FRead = FileRead($s_FilePath, FileGetSize($s_FilePath))
    $a_Array = StringRegExp($h_FRead, '(?:' & $s_Start & ')(.*?)(?:' & $s_End & ')', 3)
    If Not @error Then Return $a_Array
EndFunc

Pff, that seems groovy, but i think i'm getting to understand it :P:D:D

Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.
  • Moderators
Posted

Pff, that seems groovy, but i think i'm getting to understand it :P:D:D

What does that statement mean?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

What does that statement mean?

hahaha, ahhh... another post that has left me laughing out loud.

AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...