采集的时候遇到301,采集数据有错误

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,
true);
curl_setopt($ch
, CURLOPT_HEADER, true);
curl_setopt($ch,CURLOPT_ENCODING ,'gzip');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $header = array(
"GET /product/detail/490725/invest/0/10?_=1477377497991 HTTP/1.1",
"Host: www.xiaoniu88.com",
"Connection: keep-alive",
"Cache-Control: max-age=0",
"Accept: application/json, text/javascript, */*; q=0.01",
"X-Requested-With: XMLHttpRequest",
"User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36",
"Referer: http://www.xiaoniu88.com/product/planning/detail/490725",
"Accept-Encoding: gzip, deflate, sdch",
"Accept-Language: zh-CN,zh;q=0.8,en;q=0.6",
'Cookie: sr=334.127.201.43.11.3.43.224.47.109.0.33.20.15.07; JSESSIONID=ABDA9A33E61801B02E7064AA6D50EFAF.t-9003; lcksid=59916c534e4cea0024d7691c; SESSIONID=38acb08a-32a5-4043-a9e5-8c52a48916f4; referer="https://www.xiaoniu88.com/user/_2017-08-14"; _gat=1; _ga=GA1.2.1713379385.1502698882; _gid=GA1.2.1557902220.1502698882; Hm_lvt_7226b8c48cd07619c7a9ebd471d9d589=1502698882; Hm_lpvt_7226b8c48cd07619c7a9ebd471d9d589=1502702891'
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);

curl 采集的时候遇到301怎么办的更多相关文章

  1. php curl 采集

    curl 采集五个步骤: 1.curl_init()初始化curl 2.curl_setopt()设置传输数据和参数 3.curl_exec()执行传输并获取返回数据 4.curl_errono()返 ...

  2. curl采集 根据关键词 获取雅虎竞价排名

    之前写过curl批处理采集数据,这里贴上完整版本,代码很简单,废话不说,上代码,新手欢迎指教!!! 代码只写到 获取到链接了,至于排名 后边数组的键不就是排名喽... <?php /** * B ...

  3. Curl 采集乱码 gzip 原因及解决方案 utf-8

    用curl获取一个经过gzip压缩后的网页时返回乱码 原因大体就是服务器返回的Content-Encoding的值和网页的编码不同,造成curl解码出问题,直接将gzip或deflate编码的文件下载 ...

  4. 用curl采集需要登录的页面

    登陆cookie存储至自定义目录 $cookie_dir = tempnam('.', 'cookie');curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie_ ...

  5. php curl采集数据问题汇总

    1. 使用curl获取网页数据提示: "curl: (6) Could not resolve host: xxx.xxx.com ; Name or service not known&q ...

  6. php curl采集,服务器gzip压缩返回数据怎么办

    一般服务器不会胡乱返回gzip压缩的数据,一般是客户端请求的头部里包含你浏览器能接受的压缩方式, Accept-Encoding:gzip,deflate,sdch   这里是gzip .deflat ...

  7. curl 采集的时候遇到60报错怎么办?

    1.到https://curl.haxx.se/ca/cacert.pem复制下文本粘贴到文件夹cart.pem 然后把catr.pem放到PHP的bin目录下 2.在php.ini中修改下面这句话, ...

  8. PHP curl采集

    if (function_exists('curl_init')) { //检查函数是否存在 $url = "http://***.com/"; $ch = curl_init() ...

  9. PHP curl 采集内容之规则 及图片下载方法2

    <?phpheader("Content-type:text/html; charset=utf-8");/*$pattern = '/xxx(.*)yyyy/isU'; / ...

随机推荐

  1. python list排序(正倒)以及获取重复数据

    mylist = [2,2,2,2,5,5,7,2,2,3,3,3,3] #<class 'list'>: [2, 2, 2, 2, 5, 5, 7, 2, 2, 3, 3, 3, 3] ...

  2. 洛谷 1339 [USACO09OCT]热浪Heat Wave

    [题解] 最短路.那么直接写dijkstra就好了. #include<cstdio> #include<algorithm> #include<cstring> ...

  3. Spring security 5 Authorize Configuration

    1. Spring Security 核心请求,认证配置类 WebSecurityConfigurerAdapter protected void configure(HttpSecurity htt ...

  4. springboot项目--传入参数校验-----SpringBoot开发详解(五)--Controller接收参数以及参数校验----https://blog.csdn.net/qq_31001665/article/details/71075743

    https://blog.csdn.net/qq_31001665/article/details/71075743 springboot项目--传入参数校验-----SpringBoot开发详解(五 ...

  5. JWT & HMAC-SHA256

    JWT JSON Web Tokens https://jwt.io/ https://en.wikipedia.org/wiki/JSON_Web_Token#Structure HMACSHA25 ...

  6. Linux RAR 解压缩

    1.下载 http://www.rarlab.com/download.htm 2.安装 tar zxvf rarlinux-3.8.0.tar.gz cd rar make make install ...

  7. 洛谷——P2935 [USACO09JAN]最好的地方Best Spot

    P2935 [USACO09JAN]最好的地方Best Spot 题目描述 Bessie, always wishing to optimize her life, has realized that ...

  8. Screenshot: available via screen

    在使用selenium+PhantomJS进行爬虫时候报错 selenium.common.exceptions.TimeoutException: Message: Screenshot: avai ...

  9. Spring Cloud ZooKeeper集成Feign的坑2,服务调用了一次后第二次调用就变成了500,错误:Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.n

    错误如下: 2017-09-19 15:05:24.659 INFO 9986 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refre ...

  10. sql sever 等待事件

    http://blog.csdn.net/dba_huangzj/article/details/7607844