Forum Moderators: open

Message Too Old, No Replies

Links as Substrings

Working With Source Code

         

gaucho

3:53 am on May 14, 2005 (gmt 0)

10+ Year Member



Hi,

I am looking for - no success - by a script which reading a source code from a search engine in a <textarea> or <iframe> and split out all links.

Links:' The 'substrings' which starting by 'http' and ends by 'htm or html or asp or xml or shtml or '/blank space''.

If you know any script to do this task. Please give the url where you found it!

Many thanks for any collaboration.

G.

Bernard Marx

11:22 am on May 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



str = 'boo haa href="http://www.foo.com/doo.htm" blah blah \n'
+ 'href = "http://www.foo.com.faa/daa.asp" dooo daah';

reg = /http[^"]+(asp¦[s]?htm[l]?¦xml)"/g
matches = str.match(reg)

alert(matches) // remove trailing quotemark yourself

gaucho

9:50 am on May 15, 2005 (gmt 0)

10+ Year Member



Your script makes sense, but there is a long way until running!

<script>
function spliturl(str){
str = 'boo haa href="http://www.foo.com/doo.htm" blah blah \n'
+ 'href = "http://www.foo.com.faa/daa.asp" dooo daah';
reg = /http[^"]+(asp¦[s]?htm[l]?¦xml)"/g
matches = str.match(reg)

alert(matches) // remove trailing quotemark yourself
}

</script>

G.

gaucho

2:11 pm on May 15, 2005 (gmt 0)

10+ Year Member



Delete the priot reply! It is the answer I wanted send you!

<html>
<head>
<title>Untitled</title>

<script type="text/javascript">
function narrow2() {
<!--
str = document.getElementById('txt').value;
reg = /http[^"]+(asp¦[s]?htm[l]?¦xml)"/g
matches = str.match(reg)

// -->
}
</script>

</head>

<body>

<form>
<textarea id="txt" cols=140 rows=10 name="txt">
[google.com...]
[essex.ac.uk...]
[translate.google.com...]
</textarea>
<input type="button" onclick="narrow2()">
</form>

</body>
</html>

JL

Bernard Marx

3:02 pm on May 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Er..and what happens next?