Jump to content

For Each URL!


patentu

Recommended Posts

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

<?php


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

<form method="post">
  Please enter full URL of the page to parse (including http://):<br />
  <input type="text" name="url" size="65" value="<?php echo $the_url;  ?>"/><br />
  <input type="submit" value="Parse Emails" />
</form>

<?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 . "<br />";
    }
  }
  else {
    echo "No emails found.";
  }
}

?>

Link to comment
https://forums.phpfreaks.com/topic/237171-for-each-url/
Share on other sites

If you name the input "url[]" then $_POST["url"] will be an array that you can foreach over.

foreach ((array)$_POST["url"] as $url) {
    // do your email scraping stuff
}

 

With the generosity out of the way I can ask: What's this script for?

Link to comment
https://forums.phpfreaks.com/topic/237171-for-each-url/#findComment-1219356
Share on other sites

parse email address from links

Well yeah, but what for?

 

but i don't know php where should i insert that line?

It basically goes around all the code that extracts the emails. Give it a shot.

 

and how can i make a bigger input where each line will be an url,because like this i still have only one url

The HTML is

...

Plug in appropriate numbers for rows= and cols=.

Link to comment
https://forums.phpfreaks.com/topic/237171-for-each-url/#findComment-1219379
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.