How to scan a web page and create dynamic links?

S

Sally B.

Hello,
I searched, but couldn't find answers--probably because I'm not sure
what this is called... Anyway, I have about 50 web pages and I want to
have some JavaScript that will read in a list of keywords, scan the web
page and create links on any of those keywords... Is there any way to
do this sort of thing?

Thanks!
 
H

Hywel Jenkins

Hello,
I searched, but couldn't find answers--probably because I'm not sure
what this is called... Anyway, I have about 50 web pages and I want to
have some JavaScript that will read in a list of keywords, scan the web
page and create links on any of those keywords... Is there any way to
do this sort of thing?

Doesn't http://www.intellitxt.com/ do that?
 
S

Sally B.

Interesting... but I was thinking more of just internal links (sort of
an easy way to manage content/links). But yeah, I guess that is
similar.. any scripts out there to do this?
 
O

Oscar Monteiro

I found this script that do just that, the code goes below:
/* Here is where all the magic happens.
Just enter as many additional pages that
that you want to search, then fill in the
additional listings for each page.
*/

// "Page Name","path","Page Title","Many,Key,Words","Descriptive Comments"

c=0; item[c]=new
Array("index.html","","DemoSite","index,main,start,home,front","Demonstration
search engine data about an imagined but probable internet site.");
c++; item[c]=new Array("about.htm","","About
Me","about,author,contact,email,who","Contact details and general
information about the creator of the site and what the site is about.");
c++; item[c]=new Array("links.htm","","Links
page","links,more,where,similar,friends","Links to my favourite sites which
I find interesting. Other friends sites which have similar interests to my
own.");
c++; item[c]=new Array("main.htm","main/","Main
Page","content,main,focus","The main part of my site which contains what you
have come to see. Lots of stuff like that and more great things. All in a
sub directory.");
c++; item[c]=new Array("logo.jpg","main/images/","Link
Logo","link,image,logo,graphic","The logo.jpg is just a small image which
you can place on your site as a link to me. It's in a second level
subdirectory.");

page="<html><head><title>Search Results</title></head><body
bgcolor='white'><center><table border=0 cellspacing=10 width=80%>";


function search(frm) {
win = window.open("","","scrollbars");
win.document.write(page);
txt = frm.srchval.value.split(" ");
fnd = new Array(); total=0;
for (i = 0; i < item.length; i++) {
fnd = 0; order = new Array(0, 4, 2, 3);
for (j = 0; j < order.length; j++)
for (k = 0; k < txt.length; k++)
if (item[order[j]].toLowerCase().indexOf(txt[k]) > -1 && txt[k] != "")
fnd += (j+1);
}
for (i = 0; i < fnd.length; i++) {
n = 0; w = -1;
for (j = 0;j < fnd.length; j++)
if (fnd[j] > n) { n = fnd[j]; w = j; };
if (w > -1) total += show(w, win, n);
fnd[w] = 0;
}
win.document.write("</table><br>Total found: "+total+"<br></body></html>");
win.document.close();
}
function show(which,wind,num) {
link = item[which][1] + item[which][0];
line = "<tr><td><a href='"+link+"'>"+item[which][2]+"</a> Score:
"+num+"<br>";
line += item[which][4] + "<br>"+link+"</td></tr>";
wind.document.write(line);
return 1;
}

</script>
</HEAD>



<BODY>

<center>

<form method=get action="javascript:void(0)" onsubmit="search(this); return
false;">
<tr><td><input type=text name=srchval value=""><input type=submit
value="Search"></td></tr>
</form>

</center>

</body>
 
S

Sally B.

Hi,
I tried this script and it looks like it just does a search on strings.
I'm actually looking for something that will scan an existing web page
and change some of the text (specific strings) into normal HTML links.
Anybody know of anything like that???

Thanks!
 
M

McKirahan

Sally B. said:
Hi,
I tried this script and it looks like it just does a search on strings.
I'm actually looking for something that will scan an existing web page
and change some of the text (specific strings) into normal HTML links.
Anybody know of anything like that???

Thanks!

From a requirements perspective, is this what you want to do?

Given a folder under your Web root, examine each file with an ".htm"
extension; or will this be driven from a list of files (with their paths?) ?

Given a file with a list of keywords (one per line) associated with a URL.
For example, Google=http://www.google.com/ -or- Google=www.google.com/

Examine the source of each file replacing each instance of a keyword (not
already hyperlinked) with a hyperlink to that keyword. For example, "I love
Google." becomes
"I love <a href='http://www.google.com/" target='_blank'>Google</a>."

And you may want " target='_blank'" included in the tag to have the page
open up in a new browser window.

If so, then you could have a script that processes the inputs (a folder and
a file or two files) to generate revised versions of each page.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,434
Messages
2,571,691
Members
48,796
Latest member
Greg L.

Latest Threads

Top