phpSpider 单页测试_模拟登陆

<?php

require './vendor/autoload.php';
use phpspider\core\phpspider;
use phpspider\core\requests;
use phpspider\core\selector;

// 模拟登陆
$cookies = ".Cnblogs.AspNetCore.Cookies=CfDJ8D8Q4oM3DPZMgpKI1MnYlrnbT-Q5FNFtE5gJz6EC9NUFS4s5tY90etNYfXhxBULkAtgiVUEQpu3xvGN5NbKtjWVbjipgpDGXRWmtUxERSUzEYO5aigBk64r1_Nw6qCbl7XdE7xlrkWGt3BHDHzbshM_vvpvQrYi0HcGULnWpps53kft1wmcwqebM43cygT46x9UmEDNBo0cIwjnmh6lWmr7SYPLwNvDzcIAUi1QweoR_oACumO_bb6Ui03eNcnV1EjRT8nBDmlAt4krV8Kut0Myhazr-2wFUtfX1wfFbQcODJfdsQIxtCbeUtqlVazjoR9fk1yDfdX8hhdpiJNCLHC0lQTGScnnhqSEw9GvgTVfcncWabzy0bdgOYN065sqeaiZ_YDtSXZ98cIpHf9H9PZvgbUJt_AYvfy8V_UCiiYlYjfwL0EISEgBw2vJ1lPKh6g; .CNBlogsCookie=3116D18662591FE8B4EBCF4D2CFABF26DE31EAC9B4FEEB6678596D5B0CDF03F30A4B263C5AD0D9602CFA9A9E4C9C9E8777A043F142B39F33A93820ED1DDB56E0C1015677A27075E3F87EE102495026207369F4C4; __guid=66375729.1960077102075662600.1558606026718.039; __utma=66375729.744539077.1558606027.1558606027.1558606027.1; __utmc=66375729; __utmz=66375729.1558606027.1.1.utmcsr=account.cnblogs.com|utmccn=(referral)|utmcmd=referral|utmcct=/signin; __utmt=1; __gads=ID=2255b76d980bc782:T=1558606024:S=ALNI_MYpF8olMfOsZHG-kg_ox-2_-UCy4g; monitor_count=2; __utmb=66375729.2.10.1558606027";
requests::set_cookies($cookies, 'news.cnblogs.com');


$html = requests::get("https://news.cnblogs.com/n/622397/");
$data = selector::select($html, '//*[@id="news_content"]');



var_dump($data);

 今天练习爬虫, 爬文章爬到一半突然提示content没爬到, 后来用单页测试发现其实是没有登陆, 现在用cookie 模拟登陆, 具体看手册

posted @ 2019-05-23 18:16  Skrillex  阅读(560)  评论(0编辑  收藏  举报

power by Skrillex 2008