ruby做的网页抓取?与python 比做这样的优势是?
<?phpheader("Content-type: text/html; charset=utf-8");
@set_time_limit(0);
error_reporting(E_ALL);
$cookie_file = tempnam("./temp","cookie") or die('cookie create failed');
$post_url="http://www.jqw888.com/user.php";
$post="username=request&password=123456&act=act_login&back_act=user.php&submit=";
$login=curl_init($post_url);
curl_setopt($login,CURLOPT_HEADER,0);
curl_setopt($login,CURLOPT_RETURNTRANSFER,1);
curl_setopt($login,CURLOPT_POST,1);
curl_setopt($login,CURLOPT_COOKIEJAR,$cookie_file);
curl_setopt($login,CURLOPT_POSTFIELDS,$post);
$data=curl_exec($login);
curl_close($login);
$urls = file('./url-list.txt');//璇诲彇URL鐨勬枃浠?
$regex_name = '/<td.*?>濮撳悕锛?\/td>\s*?<td.*?>(.*?)<\/td>/i';
$regex_phone= '/<td.*?>鑱旂郴鐢佃瘽锛?\/td>\s*?<td.*?>(.*?)<\/td>/i';
$fp = @fopen('./user-list.txt','w');//鍐欏叆淇℃伅鐨勯棶棰?
$i = 1;
foreach($urls as $url){
$tmp_name = $tmp_phone = array();
if(trim($url) == 'END')break;
$cont=curl_init(trim($url));
curl_setopt($cont,CURLOPT_HEADER,0);
curl_setopt($cont,CURLOPT_RETURNTRANSFER,1);
curl_setopt($cont,CURLOPT_COOKIEFILE,$cookie_file);
$contes=curl_exec($cont);
curl_close($cont);
preg_match_all($regex_name,$contes,$tmp_name);
preg_match_all($regex_phone,$contes,$tmp_phone);
$info = $i.','.$tmp_name.','.$tmp_phone."\r\n";
echo nl2br($info);
fwrite($fp,$info);
flush();
ob_flush();
sleep(1);
$i++;
}
fclose($fp);
?>
请问这是用ruby做的网页抓取吗?好像不用装什么东西就直接能运行。高手帮忙解释下吧,最好能标出哪句是ruby。我很菜,没学过ruby和python ,想学一门的,苦于不知如何选择!!!
01.<?php
...
47. ?> 回复 2# zhlong8
这都是ruby吗?
好吧! 谢谢啦! 我怀疑这是标题党, 我们都被楼主忽悠了 难道是因为我的回答返回的是个真值,下次我一定回答 nil 回复 4# Sevk
怎么假了呢?问题代表个人 to feibuhui:
还是我来挑明了说吧。
你的代码开头:<?php这不是都说明白了嘛。是PHP,PHP,PHP啊。既不是Ruby,也不是Python啊,是PHP,PHP,PHP啊 :<
抱歉,实在是憋不住了。 回复 8# bugbugbug3
因为这代码作者说是要用python 做。以为ruby可以嵌套在 网页中。这样思考有什么不对?结果被鄙视! 这样思考:victory:
页:
[1]
2