By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,473 Members | 1,267 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,473 IT Pros & Developers. It's quick & easy.

How to scan a web page and create dynamic links?

P: n/a
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!

Jul 23 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
In article <11**********************@c13g2000cwb.googlegroups .com>,
sa**********@yahoo.com says...
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?

--
Hywel http://kibo.org.uk/
I do not eat quiche.
Jul 23 '05 #2

P: n/a
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?

Jul 23 '05 #3

P: n/a
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[i] = 0; order = new Array(0, 4, 2, 3);
for (j = 0; j < order.length; j++)
for (k = 0; k < txt.length; k++)
if (item[i][order[j]].toLowerCase().indexOf(txt[k]) > -1 && txt[k] != "")
fnd[i] += (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>
"Sally B." <sa**********@yahoo.com> escreveu na mensagem
news:11*********************@z14g2000cwz.googlegro ups.com...
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?

Jul 23 '05 #4

P: n/a
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!

Jul 23 '05 #5

P: n/a
"Sally B." <sa**********@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
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.
Jul 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.