php抓取这个页面的内容 php 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $url = "http://www.mafengwo.cn/yj/10206/2-0-1.html";$opts = array( 'http'=>array( 'timeout'=>10, 'header'=>"User-Agent: php\r\n" . "Cookie: foo=bar\r\n" ));$context = stream_context_create($opts);$data = file_get_contents($url,false,$context)这样可以读取到页面 没关系,加一个上下文(context)就可以了include 'simple_html_dom.php';$opts = array( 'http'=>array( 'user_agent' => $_SERVER['HTTP_USER_AGENT'] ) ); $context = stream_context_create($opts); $url = 'http://www.mafengwo.cn/yj/10206/2-0-1.html';$html = file_get_html($url, false, $context); 不至于吧?include 'simple_html_dom.php';$opts = array( 'http'=>array( 'user_agent' => $_SERVER['HTTP_USER_AGENT'] ) ); $context = stream_context_create($opts); $url = 'http://www.mafengwo.cn/yj/10206/2-0-1.html'; $html = file_get_html($url, false, $context);$div = $html->find('div.post-list ul');foreach($div[0]->find('li') as $i=>$item) { echo $item->find('img')[0]->src, PHP_EOL; echo trim($item->find('h2')[0]->text()), PHP_EOL; echo trim($item->find('div')[3]->text()), PHP_EOL; //echo '**', $item->innertext(), PHP_EOL;} php发送邮件问题 IE下就是不能正常操作,求高手指点 请问一下这个功能curl能实现吧? 正则相关 php 数组取 在线等,急....~~~~~~~~~~~ 为什么页面不能做跳转? 请问PHP能否调用动态链接库DLL?如果能,怎么调用? 楚狂人,还是路径问题 php获取sitemap里面指定数量的网址URL并且保存到本地的TXT文本里面 php使用beast加密代码出现的问题 前辈们帮我看一下下面的代码错在哪里 base64算法取消
$opts = array(
'http'=>array(
'timeout'=>10,
'header'=>"User-Agent: php\r\n" .
"Cookie: foo=bar\r\n"
)
);
$context = stream_context_create($opts);
$data = file_get_contents($url,false,$context)这样可以读取到页面
$opts = array(
'http'=>array(
'user_agent' => $_SERVER['HTTP_USER_AGENT']
)
);
$context = stream_context_create($opts);
$url = 'http://www.mafengwo.cn/yj/10206/2-0-1.html';$html = file_get_html($url, false, $context);
$opts = array(
'http'=>array(
'user_agent' => $_SERVER['HTTP_USER_AGENT']
)
);
$context = stream_context_create($opts);
$url = 'http://www.mafengwo.cn/yj/10206/2-0-1.html';
$html = file_get_html($url, false, $context);
$div = $html->find('div.post-list ul');
foreach($div[0]->find('li') as $i=>$item) {
echo $item->find('img')[0]->src, PHP_EOL;
echo trim($item->find('h2')[0]->text()), PHP_EOL;
echo trim($item->find('div')[3]->text()), PHP_EOL;
//echo '**', $item->innertext(), PHP_EOL;
}