Link to home
Start Free TrialLog in
Avatar of bsharath
bsharathFlag for India

asked on

Get all email id's on the open web page.When run a script.

Hi,
Get all email id's on the open web page.When run a script.
I have websites that has lots of email id's.Can we get all of them to a txt file.

REgards
Sharath
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

1. is this a page you will run from your harddisc - if so you can use HTA to grab anything with a @ in it.
2. Are you planning to spam these people when you get the email addresses?
Avatar of bsharath

ASKER

No these are live webpages
Its to get these email id's and send them mails.For product enquiry.
So for a simple way:

save this as test.hta

<html>
<head>
<script>
function getEmails() {
try {
  var links = window.frames[0].document.links;
  var text = "";
  for (var i=0;i<links.length;i++) {
    var mailtoPos = links[i].href.toLowerCase().indexOf('mailto:');
    if (mailtoPos ==0) text += links[i].href.split(':')[1]+'\n'
  }
  document.forms[1].elements[0].value=text;
}
catch(e){}  
}
</script>
</head>
<body onLoad="document.forms[0].elements[0].focus();document.forms[0].elements[0].select()">
<form style="display:inline" onSubmit="this.action=this.elements[0].value; this.elements[0].focus(); this.elements[0].select()" target="if1">
Url:<input type="text" value="http://mailto.com">
</form><a href="#" onClick="getEmails(); return false">Get emails</a>
 
<form><textarea rows=10 cols=50></textarea></form>
<iframe name="if1" height="80%" width="100%" application="yes" onLoad="getEmails()"></iframe>
</body>
</html>

Open in new window

Hi,

I saved the file as Hta and put in this link
http://www.silvertouch.com/business_units/business_lenovo.htm
But could not get the email id.
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Rob....:-)))
Strange. Works fine for me

https://filedb.experts-exchange.com/incoming/ee-stuff/6915-testhta.jpg

thinkworld@...
thinkworld@...
info@...

Did you save as test.hta ???
Yes i did.Is that to do with some proxy or something.
For me when i gave the URl and clicked the button.It did nothing...
Yes i did.Is that to do with some proxy or something.
For me when i gave the URl and clicked the button.It did nothing...
mplungjan, when I output links.length with
  var links = window.frames[0].document.links;
  alert(links.length);
  var text = "";

it is zero, which means
for (var i=0;i<links.length;i++) {

will never be executed....I don't know enough about JavaScript to fix it though....

Regards,

Rob.
Did you save with extension .hta ???

It will ONLY work if loaded as an html application since otherwise you do not have the access rights to the iframe to grab the links.
Yes i saved it as Hta
I know you did, I was commenting to Rob.
@mplungian
Yeah, I know...I did save it as a HTA....I use them quite often....perhaps you and I have different security settings for HTA's or cross domain / iframe privileges.....

I haven't explored much into HTA security, but perhaps it's somewhat configurable....

Sorry mate, I just used the "Msxml2.XMLHTTP" object to read the HTTP text of the webpage....

Regards,

Rob.
I did not change anything in my security settings so if you are in a corporate situation they may have done that for you...

Proof: https://filedb.experts-exchange.com/incoming/ee-stuff/6915-testhta.jpg