https://www.xing.com/app/search?components=form%2Cresult_header%2Cbreadcrumb%2Cresult_list%2Cpaginator%2Cfilter%2Ctab_handle&op=combined&section=members&keywords=itutor
就是抓取那些人物的姓名,我用httpwatch看到地址应该就是上面,可以在contents里面看到,可是却无法用php返回内容?
求助。谢谢。
用户名:[email protected]
密码:abcd1234

解决方案 »

  1.   

    需要登录的是把?那你抓取内容的时候,把模拟登陆后的cookie也提交过去
      

  2.   

    <?php
    $ch2 = curl_init();
    curl_setopt($ch2, CURLOPT_HEADER, false);
    curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);
    $cookie_jar = realpath('cookie.txt');
    curl_setopt($ch2, CURLOPT_COOKIEFILE, $cookie_jar);
    curl_setopt($ch2,CURLOPT_REFERER,"https://www.xing.com/app/search?components=form%2Cresult_header%2Cbreadcrumb%2Cresult_list%2Cpaginator%2Cfilter%2Ctab_handle&op=combined&section=members&keywords=itutor");
    curl_setopt($ch2,CURLOPT_URL,"https://www.xing.com/app/search?components=form%2Cresult_header%2Cbreadcrumb%2Cresult_list%2Cpaginator%2Cfilter%2Ctab_handle&op=combined&section=members&keywords=itutor");
    curl_setopt ($ch2, CURLOPT_SSL_VERIFYPEER, 0);  
    curl_setopt ($ch2, CURLOPT_SSL_VERIFYHOST, 0);
    file_put_contents("test.txt",curl_exec($ch2));
      

  3.   

    其实那个cookie文件就是模拟登陆后的数据。大家不要再往登录方面考虑了,主要是ajax的数据获取的问题。
    如何获得ajax取数据的地址。代码很多,我只是贴出了一部分。
    分不成问题,只要能解决。