您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php获取网页内容

2024/8/10 5:37:45发布115次查看
1。使用xmlhttp对象,类似于asp中的activexobject对象,其实xmlhttp无非就是get和put的操作,在php里面
get的,直接用file_get_contents/fopen/readfile这些函数就是了
put的,自己写fsockopen发送也行,用net_curl也行
(直接用系统函数要简单,通用,耗费资源少)
$xhr = new com(msxml2.xmlhttp);
$xhr->open(get,http://localhost/xxx.php?id=2,false);
$xhr->send();
echo $xhr->responsetext
2。上面说的file_get_contents实现
3。上面说的fopen()实现
if ($stream = fopen('http://www.sohu.com', 'r')) {
    // print all the page starting at the offset 10
    echo stream_get_contents($stream, -1, 10);
    fclose($stream);
}
if ($stream = fopen('http://www.sohu.net', 'r')) {
    // print the first 5 bytes
    echo stream_get_contents($stream, 5);
    fclose($stream);
}
?>
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product