×

php抓取网页snoopy

php抓取网页snoopy(php抓取网页指定内容)

admin admin 发表于2023-04-03 01:10:09 浏览58 评论0

抢沙发发表评论

本文目录一览:

用php的Snoopy如何抓取网页的验证码呢?

curl就可以了

?php

header('Content-Type:image/png');

$url = "图片链接";//图片链接

$ch = curl_init();

//Cookie:PHPSESSID=121b1127dcded8702c6a1e702c40eca4

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch,CURLOPT_COOKIE,'这里是你的cookies');

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);

curl_setopt($ch, CURLOPT_TIMEOUT,0);//忽略超时

curl_setopt($ch, CURLOPT_NOBODY, false);

$str = curl_exec($ch);

curl_close($ch);

php抓取网页内容不完整

用CURL可以抓取到的 可能是你网速太慢超时了 所以抓取不完整 用 curl_setopt($ch, CURLOPT_TIMEOUT, 360) 试试看

php怎么抓取其它网站数据

可以用以下4个方法来抓取网站 的数据:

1. 用 file_get_contents 以 get 方式获取内容:

?

$url = '';

$html = file_get_contents($url);

echo $html;

2. 用fopen打开url,以get方式获取内容

?

$url = '';

$fp = fopen($url, 'r');

stream_get_meta_data($fp);

$result = '';

while(!feof($fp))

{

$result .= fgets($fp, 1024);

}

echo "url body: $result";

fclose($fp);

3. 用file_get_contents函数,以post方式获取url

?

$data = array(

'foo'='bar',

'baz'='boom',

'site'='',

'name'='nowa magic');

$data = http_build_query($data);

//$postdata = http_build_query($data);

$options = array(

'http' = array(

'method' = 'POST',

'header' = 'Content-type:application/x-www-form-urlencoded',

'content' = $data

//'timeout' = 60 * 60 // 超时时间(单位:s)

)

);

$url = "";

$context = stream_context_create($options);

$result = file_get_contents($url, false, $context);

echo $result;

4、使用curl库,使用curl库之前,可能需要查看一下php.ini是否已经打开了curl扩展

$url = '';

$ch = curl_init();

$timeout = 5;

curl_setopt ($ch, CURLOPT_URL, $url);

curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);

$file_contents = curl_exec($ch);

curl_close($ch);

echo $file_contents;

php伪造ip获取网页内容,求高手

伪造IP是不可能的,HTTP协议是机遇TCP,你发送GET命令过去必须留有准确的IP地址,否则对方无法把结果发给你,你与服务器xxx.xxx.xx的通讯相当于写信,你匿名写信只能攻击,要获取返回的东西必须提交真实的地址。-php抓取网页snoopy

无论使用CURL还是别的方法,都要受前面的基本规则限制。

编程上已经没有办法可走了,你可以考虑使用代理,通过代理服务器去获取数据,查封就换个代理服务器。不过现在代理服务器是很难找的。

关于php抓取asp网页

curl_setopt($ch,CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:36.0) Gecko/20100101 Firefox/36.0');-php抓取网页snoopy

加一行这个参数试试!!