For Each URL!

What modification should i bring to this script to make a mass parsing not only for one url,for 200 at once or more.Hope you understand,thank you

[code]<?php

$the_url = isset($_REQUEST[‘url’]) ? htmlspecialchars($_REQUEST[‘url’]) : ‘’;
?>

Please enter full URL of the page to parse (including http://):

<?php if (isset($_REQUEST['url']) && !empty($_REQUEST['url'])) { // fetch data from specified url $text = file_get_contents($_REQUEST['url']); } elseif (isset($_REQUEST['text']) && !empty($_REQUEST['text'])) { // get text from text area $text = $_REQUEST['text']; } // parse emails if (!empty($text)) { $res = preg_match_all( "/[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}/i", $text, $matches ); if ($res) { foreach(array_unique($matches[0]) as $email) { echo $email . "
"; } } else { echo "No emails found."; } } ?>[/code]

Enter the urls one choice per line:

[php]<?php
/**

  • Initialize the cURL session
    */
    $ch = curl_init();
    $the_url = isset($_REQUEST[‘url’]) ? htmlspecialchars($_REQUEST[‘url’]) : ‘’;
    ?>
Please enter full URL of the page to parse (including http://):

<?php if (isset($_REQUEST['url']) && !empty($_REQUEST['url'])) { // fetch data from specified url $urls = array(); $url = str_replace("\n",";",$_REQUEST['url']); $urls = explode(';',$url); foreach($urls as $url){ /** * Set the URL of the page or file to download. */ curl_setopt($ch, CURLOPT_URL, $url); /** * Ask cURL to return the contents in a variable * instead of simply echoing them to the browser. */ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); /** * Execute the cURL session */ $text[] = curl_exec ($ch); } } elseif(isset($_REQUEST['text']) && !empty($_REQUEST['text'])) { // get text from text area $text = $_REQUEST['text']; } // parse emails if (!empty($text)) { foreach($text as $value){ $res = preg_match_all("/[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}/i",$value,$matches); if ($res) { foreach(array_unique($matches[0]) as $email){ echo $email . "
"; } } else{ echo "No emails found."; } } } /** * Close cURL session */ curl_close ($ch); ?>

[/php]

You might need to do a bit of formatting, but from what i have tested, the code is working perfectly fine. Enjoy! :slight_smile:

is working with 2-3 urls but if i put 10 ,i get “No emails found” for all the links,what can be?

thank you

doesn’t work only with 1 url,if i put 2 urls one is ignored only the url from the first line gets parsed

Sponsor our Newsletter | Privacy Policy | Terms of Service