| View previous topic :: View next topic |
| Author |
Message |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Thu Apr 15, 2004 8:57 am Post subject: |
|
|
There may be a little problem if the anchor tag containing HREF is broken across more than one line, like this
| Code: | <A HREF="http://mysite.com"
target=_new>link</A> |
This could be one way to fix that:
| Code: |
....
REM If no space, end URL at >
else
if @EQUAL(%%pos2,0)
LIST ADD,2,@SUBSTR(%%text,1,@LEN(%%text))
%%text = @STRDEL(%%text,1,%%pos2)
else
LIST ADD,2,@SUBSTR(%%text,1,@PRED(%%pos2))
%%text = @STRDEL(%%text,1,%%pos2)
end
end
....
|
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Thu Apr 15, 2004 3:35 pm Post subject: |
|
|
This is another routine to parse urls form a input-text / website. It will put every found url into a list. The best is to use a sorted list for the output, so you won't get duplicated items...
| Code: | #define function,ParseURL
list create,1
list create,2,sorted
list add,1,<title>Test</title>
list add,1,<body>
list add,1,Text here<br>
list add,1,<a href=@chr(34)http://www.test.net/files/test/index.html@chr(34) class="test">Test</a><br>
list add,1,Links: <a href=@chr(34)index.php@chr(34) target=@chr(34)_blank@chr(34)>Visit VDSWorld</a> - <a href=@chr(34)http://forum.vdsworld.com@chr(34)>Visit VDSWorld Forum</a><br>
list add,1,E-mail: <a href=@chr(34)mailto:webmaster@CHR(64)site.com@chr(34)>webmaster@CHR(64)site.com</a><img src=@chr(34)http://imageweb/myimage.gif@chr(34)>
list add,1,http://www.taest23.nzet/fic~_vles/test/index.html? <embed src=@chr(34)flash.swf@chr(34)>http://www.taest23.nzet/fic~_vles/test/index.html?
list add,1,</body>
# The ParseURL function will take all files from the input and put it into the list specified with the second parameter.
# Syntax:
# - @ParseURL(<input text>,<output list>)
info @ParseURL(@text(1),2)
list close,2
list close,1
exit
:ParseURL
if @equal(%1,CheckValidChar)
%%string1 = @both(@greater(@asc(@substr(%2,1,1)),@pred(@asc(a))),@greater(@succ(@asc(z)),@asc(@substr(%2,1,1))))
%%string2 = @both(@greater(@asc(@substr(%2,1,1)),@pred(@asc(A))),@greater(@succ(@asc(Z)),@asc(@substr(%2,1,1))))
%%string3 = @both(@greater(@asc(@substr(%2,1,1)),47),@greater(58,@asc(@substr(%2,1,1))))
%%string4 = @equal(@substr(%2,1,1),":")@equal(@substr(%2,1,1),"/")@equal(@substr(%2,1,1),"\")@equal(@substr(%2,1,1),".")@equal(@substr(%2,1,1),"~")@equal(@substr(%2,1,1),"-")@equal(@substr(%2,1,1),"_")@equal(@substr(%2,1,1),"%")@equal(@substr(%2,1,1),"?")@equal(@substr(%2,1,1),"&")@equal(@substr(%2,1,1),"=")@equal(@substr(%2,1,1),"@")@equal(@substr(%2,1,1),";")@equal(@substr(%2,1,1),",")@equal(@substr(%2,1,1),"+")@equal(@substr(%2,1,1),"#")@equal(@substr(%2,1,1),"(")@equal(@substr(%2,1,1),")")
exit %%string1%%string2%%string3%%string4
end
%%input = %1" "
# Search for strings beginning with "http://".
%%backupinput = %%input
while @unequal(@pos("http://",%%input),0)
%%input = @strdel(%%input,1,@pred(@pos("http://",%%input)))
%%output =
repeat
%%output = %%output@substr(%%input,1,1)
%%input = @strdel(%%input,1,1)
until @not(@ParseURL(CheckValidChar,%%input))
list add,%2,%%output
wend
# Now search for "<a href="blabla.html".
%%input = %%backupinput
while @greater(@pos("<a href=",%%input),0)
%%input = @trim(@strdel(%%input,1,@sum(@pos("<a href=",%%input), ))
%%output =
repeat
%%output = %%output@substr(%%input,1,1)
%%input = @strdel(%%input,1,1)
until @not(@ParseURL(CheckValidChar,%%input))
list add,%2,%%output
wend
# Also search for images: "<img src=".
%%input = %%backupinput
while @greater(@pos("<img src=",%%input),0)
%%input = @trim(@strdel(%%input,1,@sum(@pos("<img src=",%%input),9)))
%%output =
repeat
%%output = %%output@substr(%%input,1,1)
%%input = @strdel(%%input,1,1)
until @not(@ParseURL(CheckValidChar,%%input))
list add,%2,%%output
wend
# And for embedded things: "<embed src="
%%input = %%backupinput
while @greater(@pos("<embed src=",%%input),0)
%%input = @trim(@strdel(%%input,1,@sum(@pos("<embed src=",%%input),11)))
%%output =
repeat
%%output = %%output@substr(%%input,1,1)
%%input = @strdel(%%input,1,1)
until @not(@ParseURL(CheckValidChar,%%input))
list add,%2,%%output
wend
exit @text(%2) |
_________________ [ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial! |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|