WebParser

[Total: 0    Average: 0/5]

This script will parse html code and pull out links and email addresses.

Head Code:

<SCRIPT LANGUAGE="JavaScript">

function findAllTheUrlAddresses(StrObj) {
var separateurlBy = ", ";
var url = "<none url present>"; // if no match, use this
var urlArray = StrObj.match(/([a-zA-Z]+tp://[a-zA-Z0-9._-]+)/gi);
if (urlArray) {
url = "";
for (var i = 0; i < urlArray.length; i++) {
if (i != 0) url += separateurlBy;
url += urlArray[i];
      }
   }
return url;
}


function findAllTheWwwAddresses(StrObj) {
var separatewwwsBy = ", ";
var www = "<none www present>"; // if no match, use this
var wwwsArray = StrObj.match(/(www[a-zA-Z0-9._-]+)/gi);
if (wwwsArray) {
www = "";
for (var i = 0; i < wwwsArray.length; i++) {
if (i != 0) www += separatewwwsBy;
www += wwwsArray[i];
      }
   }
return www;
}


function findAllTheEmailAddresses(StrObj) {
var separateEmailsBy = ", ";
var email = "<none e-mail present>"; // if no match, use this
var emailsArray = StrObj.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+.[a-zA-Z0-9._-]+)/gi);
if (emailsArray) {
email = "";
for (var i = 0; i < emailsArray.length; i++) {
if (i != 0) email += separateEmailsBy;
email += emailsArray[i];
      }
   }
return email;
}
</script>

Body Code:

<TABLE WIDTH="600" border="0" cellpadding="0" cellspacing="0"><TR><TD>

<form name=form>

<input type=button value=" original text " onClick="javascript:this.form.original.focus();this.form.original.select();"><BR>
<textarea name=original rows=3 cols=50 onBlur="this.form.url.value=findAllTheUrlAddresses(this.value);this.form.www.value=findAllTheWwwAddresses(this.value);this.form.email.value=findAllTheEmailAddresses(this.value);">
</textarea><p>

<input type=button value=" select url's " onClick="javascript:this.form.url.focus();this.form.url.select();">
<BR><textarea name=url rows=3 cols=50></textarea><p>

<input type=button value=" select www's " onClick="javascript:this.form.www.focus();this.form.www.select();">
<BR><textarea name=www rows=3 cols=50></textarea><p>

<input type=button value=" select e-mails " onClick="javascript:this.form.email.focus();this.form.email.select();">
<BR><textarea name=email rows=3 cols=50></textarea>
</center>
</form>
</TD></TR></TABLE>
This should go into your BODY TAG!
<BR>
onLoad="document.form.original.focus()"

Times Viewed: 2

Leave a Reply

Your email address will not be published. Required fields are marked *