forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Find URL
Goto page Previous  1, 2
 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Thu Apr 15, 2004 6:53 am    Post subject: Reply with quote

I'm now working on some code which can also parse URLs from sites, even if they aren't mentioned in a <a href=""> tag... Smile I think I'll be done this evening (about 12 hours from now)... Smile
_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Thu Apr 15, 2004 8:57 am    Post subject: Reply with quote

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
View user's profile Send private message
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Thu Apr 15, 2004 3:35 pm    Post subject: Reply with quote

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

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),Cool))
  %%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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
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

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group