Note that there are some explanatory texts on larger screens.

plurals
  1. POparsing multiple urls from the form
    primarykey
    data
    text
    <p>I'm trying to make a script, which search the list of urls given in the form for the email adresses. Could anyone advice me how to do it? Is there some alternative to cURL? I tried to make it with file_get_contents, but the script analyze only the last url given in the form: when I enter for example two urls to the form, the first "print_r("show current_url:". $current_url); is empty and for the second it shows the page(url) content(without pictures).</p> <p>I asked on different forums, but received no answer. Will really appraciate your help.</p> <p>Thank you <pre><code>$urls = explode("\n", $_POST['urls']); $db = new mysqli('localhost', 'root', 'root', 'urls'); if (mysqli_connect_errno()) { echo 'B&amp;#322;&amp;#261;d: '; exit; } for ($i=0; $i&lt;count($urls); $i++){ print_r("show link:". $urls[$i]."&lt;br&gt;"); $current_url = file_get_contents($urls[$i]); print_r("show current_url:". $current_url); preg_match( "/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $current_url, $email);//email print_r ("show email:".$email[0]); $query = "INSERT INTO urle set adres = '$email[0]' "; $result = $db-&gt;query($query); } if ($query) { echo $db-&gt;affected_rows ."pozycji dodano."; } else { echo mysql_errno() . ":" . mysql_error() . "Wyst&amp;#261;pi&amp;#322; b&amp;#322;&amp;#261;d przy dodawaniu urli "; } $db-&gt;close(); ?&gt; </code></pre> <hr> <p>EDIT: I have tried with curl. var_dump($email); shows: array(0) { } The script displays now all of the urls given in the form in the browser, but preg_match doesn't work, so it doesn't extract email adresses.</p> <pre><code>&lt;?php $urls = explode("\n", $_POST['urls']); $db = new mysqli('localhost', 'root', 'root', 'linki'); if (mysqli_connect_errno()) { echo 'Błąd: '; exit; } for ($i=0; $i&lt;count($urls); $i++){ $url = $urls[$i]; $ch = curl_init($url); curl_setopt($ch, CURLOPT_URL, $url); $output = curl_exec($ch); preg_match( "/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $output, $email);//email var_dump($email); $query = "INSERT INTO urle set adres = '$email[0]' "; $result = $db-&gt;query($query); curl_close($ch); }// if ($result) { echo $db-&gt;affected_rows ."pozycji dodano."; } else { echo mysql_errno() . ":" . mysql_error() . "Wystąpił błąd przy dodawaniu urli "; } $db-&gt;close(); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload