Visualizzazione dei risultati da 1 a 5 su 5
  1. #1

    estrarre indirizzi email da elenco

    ho un elenco pazzesco in formato txt di indirizzi email e devo spedire una mail unica a tutti: per evitare di scriverli a mano (sarebbe la morte anche copiarli ed incollarli), ho fatto uno script, ma non funziona a dovere. mi potete dare una mano?

    esempio

    indirizzo1@email.com descrizione1
    indirizzo2@email.com descrizione2
    indirizzo3@email.com descrizione3
    indirizzo4@email.com descrizione4

    eccetera


    che deve diventare

    indirizzo1@email.com; indirizzo2@email.com; indirizzo3@email.com; indirizzo4@email.com;

    eccetera

    codice:
    <html>
    <head>
    <script language="javascript">
    
    function trovaemail() {
    
    contenuto = document.getElementById('indirizzi').value;
    
    indir = contenuto.split(" ");
    
    for (x=0; x<indir.length; x++) {
    
    if (indir[x].indexOf("@")!=-1) {
    document.getElementById('risultati').value += indir[x] + "; "
    }
    }
    
    }	
    
    
    </script>
    
    
    
    </head>
    <body>
    <textarea id="indirizzi" cols="20" rows="10"></textarea>
    
    <input type="button" value="reset indirizzi" 
    
    onclick="document.getElementById('indirizzi').value='';">
    
    
    <textarea id="risultati" cols="20" rows="10"></textarea>
    
    <input type="button" value="reset risultati" 
    
    onclick="document.getElementById('risultati').value='';">
    
    
    
    <input type="button" value="trova email" onclick="javascript:trovaemail();">
    </body>
    </html>

  2. #2
    Utente di HTML.it
    Registrato dal
    Jul 2003
    Messaggi
    667
    che dichi ti può picere???

    codice:
    <HTML>
    <HEAD>
    <SCRIPT LANGUAGE="JAVASCRIPT" TYPE="text/javascript">
    <!-- Begin
    
    // Created and Copyrighted by Benjamin Leow
    // Please go to http://www.surf7.net for latest version and more freeware
    
    function copy() {
    textRange = document.extractor.output.createTextRange();
    textRange.execCommand("RemoveFormat");
    textRange.execCommand("Copy");
    }
    
    function paste() {
    textRange = document.extractor.input.createTextRange();
    textRange.execCommand("RemoveFormat");
    textRange.execCommand("Paste");
    }
    
    function help(){
    
    var imgwid = 450;
    var imghgt = 335;
    
    content = ('<html><head><title>Email Extractor Lite : Help</title>');
    content += ('<STYLE TYPE="text/css">');
    content += ('BODY,td,th,ul,p       { font: normal normal normal 8pt/1em Verdana; color: #000; }');
    content += ('</STYLE>');
    content += ('</head><body onload="window.focus();">');
    content += ('Quick and dirty');
    content += ('
    1. '); content += ('<LI>Copy all text from any webpages, documents, files, etc...'); content += ('<LI>Paste it into Input Window.'); content += ('<LI>Click "Extract" button.'); content += ('<LI>Copy the result from Output Window to somewhere and save it.'); content += ('<LI>Click "Reset" button to start all over again.'); content += ('
    '); content += (' More Controls'); content += ('
    1. '); content += ('<LI>Click "Paste Input" link to paste any text you copied elsewhere into Input Window.'); content += ('<LI>Click "Copy Output" link to copy whatever text inside Output Window.'); content += ('<LI>Choose different separator from the dropdown menu or specify your own. Default is comma.'); content += ('<LI>You can group a number of emails together. Each group is separated by a new line. Please enter number only.'); content += ('<LI>Check "Sort Alphabetically" checkbox to arrange extracted emails well... alphabetically.'); content += ('<LI>You can extract emails containing only certain string (text). Useful if you only want to get email from a particular domain.'); content += ('
    '); content += ('<DIV ALIGN="CENTER"><INPUT TYPE="button" VALUE="Close" onClick="javascript:window.close();"></DIV>'); content += ('</body></html>'); var winl = (screen.width - imgwid) / 2; var wint = (screen.height - imghgt) / 2; helpwindow = window.open('','help','width=' + imgwid + ',height=' + imghgt + ',resizable=0,scrollbars=0,top=' + wint + ',left=' + winl + ',toolbar=0,location=0,directories=0,status=0,menubar=0,copyhistory=0'); helpwindow.document.write(content); helpwindow.document.close(); } function checksep(value){ if (value) document.extractor.sep.value = "other"; } function numonly(value){ if (isNaN(value)) { window.alert("Please enter a number or else \nleave blank for no grouping."); document.extractor.groupby.focus(); } } function findEmail() { var email = "No email address detected"; var a = 0; var ingroup = 0; var separator = document.extractor.sep.value; var string = document.extractor.string.value; var groupby = Math.round(document.extractor.groupby.value); if (separator == "new") separator = "\n"; if (separator == "other") separator = document.extractor.othersep.value; var rawemail = document.extractor.input.value.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi); var norepeat = new Array(); var filtermail = new Array(); if (rawemail) { if (string){ x = 0; for (var y=0; y<rawemail.length; y++) { if (rawemail[y].search(string) >= 0) { filtermail[x] = rawemail[y]; x++; } } rawemail = filtermail; } for (var i=0; i<rawemail.length; i++) { var repeat = 0; // Check for repeated emails routine for (var j=i+1; j<rawemail.length; j++) { if (rawemail[i] == rawemail[j]) { repeat++; } } // Create new array for non-repeated emails if (repeat == 0) { norepeat[a] = rawemail[i]; a++; } } if (document.extractor.sort.checked) norepeat = norepeat.sort(); // Sort the array email = ""; // Join emails together with separator for (var k = 0; k < norepeat.length; k++) { if (ingroup != 0) email += separator; email += norepeat[k]; ingroup++; // Group emails if a number is specified in form. Each group will be separate by new line. if (groupby) { if (ingroup == groupby) { email += '\n\n'; ingroup = 0; } } } } // Return array length var count = norepeat.length; // Print results document.extractor.count.value = count; document.extractor.output.value = email; } // End --> </SCRIPT> <STYLE TYPE="text/css"> BODY { background:#FFF } BODY,td,th,ul,p { font: normal normal normal 8pt/1em Verdana; color: #000; } textarea,input,select { font: normal normal normal 8pt/1em Verdana; color: #000; } A:link, A:visited { text-decoration: none; color: #059; } A:active, A:hover { text-decoration: underline; color: #D14; } .bordercolor { background:#666 } .maincolor { background:#CCC } .button { background:#CCC } .titlebarcolor { background:#007 } .titlefont { font: normal normal bold 9pt/1em Arial; color: #FFF; } .copyrightfont { font: normal normal normal 7.5pt/1.5em Verdana; color: #666; } </STYLE> <TITLE>Email Extractor Lite 1.5</TITLE> </HEAD> <BODY> <DIV ALIGN="CENTER"> <FORM NAME="extractor"> <TABLE CLASS="bordercolor" CELLPADDING=1 CELLSPACING=0 BORDER=0><TR><TD> <TABLE CLASS="maincolor" CELLPADDING=4 CELLSPACING=0 BORDER=0> <TR CLASS="titlebarcolor" VALIGN="MIDDLE"> <TD><FONT CLASS="titlefont">Email Extractor Lite 1.5</FONT></TD> <TD ALIGN="RIGHT" NOWRAP></TD> </TR> <TR> <TD VALIGN="TOP" ALIGN="CENTER" WIDTH="50%"> Input Window <TEXTAREA NAME="input" rows=8 cols=50></TEXTAREA> </TD> <TD VALIGN="TOP" ALIGN="CENTER" WIDTH="50%"> Output Window <TEXTAREA NAME="output" rows=8 cols=50></TEXTAREA> </TD></TR> <TR> <TD VALIGN="TOP" ALIGN="CENTER"> <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> <!-- if ((navigator.appName=="Microsoft Internet Explorer")&&(parseInt(navigator.appVersion)>=4)) document.write('Paste Input'); else document.write('Paste Input'); // --> </SCRIPT> </TD> <TD VALIGN="TOP" ALIGN="CENTER"> <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> <!-- if ((navigator.appName=="Microsoft Internet Explorer")&&(parseInt(navigator.appVersion)>=4)) document.write('Copy Output'); else document.write('Copy Output'); // --> </SCRIPT> </TD></TR> <TR> <TD VALIGN="TOP" ALIGN="LEFT" COLSPAN=2> Separator: <SELECT NAME="sep"> <OPTION VALUE=", ">Comma</OPTION> <OPTION VALUE="|">Pipe</OPTION> <OPTION VALUE=" : ">Colon</OPTION> <OPTION VALUE="new">New Line</OPTION> <OPTION VALUE="other">Other</OPTION> </SELECT> <INPUT TYPE="TEXT" NAME="othersep" SIZE=3 onBlur="checksep(this.value)"> Group: <INPUT TYPE="TEXT" SIZE=3 NAME="groupby" onBlur="numonly(this.value)"> Emails <LABEL FOR="sortbox"><INPUT TYPE="CHECKBOX" NAME="sort" id="sortbox">Sort Alphabetically</LABEL> </TD></TR> <TR> <TD VALIGN="TOP" ALIGN="LEFT" COLSPAN=2> Only extract email containing this string: <INPUT TYPE="TEXT" SIZE=20 NAME="string"> </TD></TR> <TR> <TD VALIGN="TOP" ALIGN="LEFT"> <INPUT TYPE="BUTTON" CLASS="button" VALUE="Extract" onClick="findEmail()"> <INPUT TYPE="RESET" CLASS="button" VALUE="Reset"> Need help? </TD> <TD VALIGN="TOP" ALIGN="RIGHT" NOWRAP> Email count: <INPUT NAME="count" SIZE=5 READONLY> </TD></TR> </TABLE> </TD></TR></TABLE> </FORM> <FONT CLASS="copyrightfont">&copy; 2002, 2003 Benjamin Leow - All Right Reserved Go to Surf7 Network for latest version and more freeware.</FONT> </DIV> </BODY> </HTML>

  3. #3
    mi potrebbe anche piacere se funzionasse

  4. #4
    Utente di HTML.it L'avatar di willybit
    Registrato dal
    May 2001
    Messaggi
    4,367
    basterebbe una regular expression
    codice:
    <script>
    function TrovaEmail(ff){
      var re = /[\w\-\.]+@([\w\-]+\.)+[a-z]{2,4}\]?/gi
      var stringa = ff.txt.value
      var ris = stringa.match(re)
      var strEmail=''
      for(var i=0;i<ris.length;i++)
        strEmail+=(ris[i]+'; ')
      ff.email.value=strEmail
    }
    </script>
    <form>
    <textarea name="txt" cols="80" rows="10"></textarea>
    
    
    <input type="button" value="Trova indirizzi email" onclick="TrovaEmail(this.form)">
    
    
    <textarea name="email" cols="80" rows="10"></textarea>
    </form>

  5. #5
    no nso come ringraziarti, davvero

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.