Quantcast
Channel: CNode:Node.js专业中文社区
Viewing all articles
Browse latest Browse all 14821

爬取网页时,返回的页面代码中包含JavaScript定时重定向问题

$
0
0

大哥大姐们帮帮忙,谢谢!

起因:我在使用async模块进行异步并发访问一个PHP网站,url格式如下: http://…/zt_shop_order_list.php?xm=&page=1 http://…/zt_shop_order_list.php?xm=&page=2 … http://…/zt_shop_order_list.php?xm=&page=51

url需要设置cookie:

const cookie = ‘zt_user2=123456789; a=1; b=1; d=1; f=1; js=%E8%B4%A2%E5%8A%A1%E7%AE%A1%E7%90%86’

爬去代码如下: var fetchUrl = function (url, callback) { superagent .get(url) .set(‘Cookie’, cookie) .end(function (err, sres) { callback(null, sres.text); }) };

问题:前面几十个url都可以正常爬取数据,但是到 http://…/zt_shop_order_list.php?xm=&page=51时,页面代码就变成了下面的样子: <html> <head> <meta http-equiv=“Content-Type” content=“text/html; charset=gb2312” /> <meta http-equiv=“pragma” content=“no-cache” /> <meta http-equiv=“cache-control” content=“no-store” /> <meta http-equiv=“Connection” content=“Close” /> <script> function JumpSelf(){
self.location="/…/zt_shop_order_list.php?xm=&page=52&WebShieldSessionVerify= ZKQ1syEzTq6dePTJPW6r";} </script> <script> setTimeout(“JumpSelf()”,700); </script> </head> <body></body> </html>

请问这是什么原因?


Viewing all articles
Browse latest Browse all 14821

Trending Articles