Php .txt->;卷曲->;Pregmetch->;Mysql

Php .txt->;卷曲->;Pregmetch->;Mysql,php,mysql,curl,preg-match,Php,Mysql,Curl,Preg Match,1) 而不是http://webiste.com/filename我想从.txt文件中获取数据,该文件包含20374行,每行包含不同的网站 例如: website1.com website2.com website3.com etc. 2) 使用curl命令分别解析它们 3) 通过preg\u match 4) 以及我想保存到mysql数据库的最终结果 下面是我目前正在使用的代码,请告知解决方案需要添加哪些内容才能实现此目标 function curl($url) { $agent =

1) 而不是
http://webiste.com/filename
我想从
.txt
文件中获取数据,该文件包含20374行,每行包含不同的网站

例如:

website1.com
website2.com
website3.com
etc.
2) 使用curl命令分别解析它们

3) 通过
preg\u match

4) 以及我想保存到mysql数据库的最终结果

下面是我目前正在使用的代码,请告知解决方案需要添加哪些内容才能实现此目标

function curl($url)
{
    $agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)";
    $ch = curl_init();
    $timeout = 5;
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Cookie: ddosdefend=1d4607e3ac67b865e6c7263260c34e888cae7c56")); 
    curl_setopt($ch, CURLOPT_USERAGENT, $agent); // The contents of the "User-Agent: " header to be used in a HTTP request. 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  // TRUE to return the transfer as a string of the return value of curl_exec() instead of outputting it out directly. 
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // TRUE to follow any "Location: " header that the server sends as part of the HTTP header (note this is recursive, PHP will follow as many "Location: " headers that it is sent, unless CURLOPT_MAXREDIRS is set). 
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}

$test = curl('http://webiste.com/filename');
preg_match('/<iframe class=\"metaframe rptss\" src="(.*?)"/', $test, $matches);

$test2 = $matches[1];
函数curl($url)
{
$agent=“Mozilla/5.0(Windows;U;Windows NT 5.0;en-US;rv:1.4)Gecko/20030624 Netscape/7.1(ax)”;
$ch=curl_init();
$timeout=5;
curl_setopt($ch,CURLOPT_HTTPHEADER,array(“Cookie:ddosdefend=1d4607e3ac67b865e6c7263260c34e888cae7c56”);
curl_setopt($ch,CURLOPT_USERAGENT,$agent);//要在HTTP请求中使用的“User agent:”头的内容。
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);//TRUE以curl_exec()返回值的字符串形式返回传输,而不是直接输出。
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);//如果在服务器作为HTTP头的一部分发送的任何“Location:”头后面加上TRUE(注意,这是递归的,除非设置了CURLOPT_MAXREDIRS,否则PHP将在发送的“Location:”头后面加上同样多的头)。
curl_setopt($ch,CURLOPT_URL,$URL);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data=curl\u exec($ch);
卷曲关闭($ch);
返回$data;
}
$test=curl($test)http://webiste.com/filename');

preg_match('/将文件读入带有
文件(“filename”,file_IGNORE\u NEW\u line)的数组中)
,然后使用
foreach
在数组上循环。你的意思是要卷曲20374个网站吗?@hassan well这是一个网站的20374个页面,但想法是相同的