抓取url和网页内容

WBOY
Release: 2016-06-23 14:38:32
Original
815 people have browsed it

由于技术不够,整天在逛论坛。 看到许多关于抓取网页内容(file_get_contents)和抓取url(这个不知道用什么)对这个听感兴趣。望大神指点下这是怎么回事?最好能帮我整个源码嘎嘎。叫我参考下。


回复讨论(解决方案)

自己百度先吧

我用 php socket 和 curl写过真实的例子,至于 file_get_contents更简单了,原理都一样,你看以看看
不足之处请指点,
http://blog.csdn.net/zkg510168343/article/details/12996699
http://blog.csdn.net/zkg510168343/article/details/16983161

curl
手册里有例子,必须要看手册阿

百度一下,可以找到很多的。

百度 php  采集

baidu下 file_get_contents()和curl 抓取采集

$url='http://www.iheima.com/';
$con=file_get_contents($url);
if ($con){

preg_match_all('/

(.+).*

(.+)/isU', $con, $temp,PREG_SET_ORDER);
foreach ($temp as $key=> $v){
$title=$v[2];
$v_url=$v[1];
$des=$v[3];
$con_url=file_get_contents($v_url);
if ($con_url){
$tags='';
preg_match('/keywords" content="(.+)"/isU', $con_url,$tags);
$tags=trim($tags[1],',');

preg_match('/class="txs_Content".*>(.+)/isU', $con_url,$txt);
$txt=$txt[1];
}

}
} 够清楚了吧

有个开源的simple_html_dom
$html = file_get_html('http://www.baidu.com');
可以根据各种抓取,如id,css等方法抓取网页内容

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!