为什么卷曲响应显示为假?

时间:2019-07-11 21:07:04

标签: php curl

我正在通过curl从list.txt连接到某些网站,在源中搜索一个单词,并将每个单词保存在文本文件中。我的问题是我只看到list.txt中最后一个网站的结果。我该如何解决?

<?php

$text = file_get_contents('text.txt');    
$values = preg_split('/[\n,]+/', $text);

foreach ($values as $url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $content=curl_exec($ch);

    $html = strstr(htmlspecialchars($content),"data: { mailto:");
    $email = substr($html,22,30);

    $myfile = fopen("newfile.txt", "a") or die("Unable to open file!"); 
    fwrite($myfile, $email);
    fwrite($myfile, "\r\n");
    fclose($myfile);
    curl_close($ch);
}

?>

0 个答案:

没有答案