如何越过“请在微信客户端打开”

2018-05-17  本文已影响0人  chinariver

最近,发现,在pc端浏览器打开微信的链接,比如以下链接:

https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MjM5NjI2ODA4Mw==&scene=124#wechat_redirect

出现了,讨厌的下图

我想,微信这么做,应该有自己的考虑,让你,必须玩客户端,防止数据采集,

而我正是想做数据采集的,想了一下午,结果出来了,

注:以下方法是在微信链接的有效期内,可以正常访问,过期后,失效,还是一样的烦人提示

看我的脚本代码

基于Yii2.0的console:

controller:

public function actionPwx()

{

    $url = 'https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MjM5NjI2ODA4Mw==&scene=124&devicetype=iOS11.3.1&version=16060622&lang=zh_CN&nettype=WIFI&a8scene=1&fontScale=100&pass_ticket=MY3aBcoqvB2cTBEJJnP%2BVPSXyJtSOfZ0E%2F8reJ%2B0f%2Bs3LCYq3uhdfa8ZJGj8cnp0&wx_header=1';

    $cookie = 'Cookie: devicetype=iOS11.3.1; lang=zh_CN; pass_ticket=MY3aBcoqvB2cTBEJJnP+VPSXyJtSOfZ0E/8reJ+0f+s3LCYq3uhdfa8ZJGj8cnp0; version=16060622; wap_sid2=CLTElqcIElwybUlJb3ZNZFJNV0d4d3lOQXA1OWdkUG45V2lzREZCQl9yZ045Mk5UWl85NUpGc195cjNadWM3NWlJNW44b3IzYW43NDhPd0VYR3pQcTRYQnRBc1p0YjBEQUFBfjC+3vTXBTgNQJVO; wxuin=2229641780';

    $wxUin = 'MjIyOTY0MTc4MA%3D%3D';

    $wxKey = 'da918ddff46931c05b6772851ba568473f739a5d527719f84ccdc30a441fd56965be7cc9830948ead79fb25e487622710bdf0b0e0115551d85d9ef88969f0f202016e8f599f20ecaf91dcd6181fd17cb';

    $html = Tools::curl_weixin($url, '', $cookie, $wxKey, $wxUin);

    $html = gzinflate($html);

    var_dump($html);

}

Tools中的curl_weixin();

public static function curl_weixin($url, $referer = '', $cookie = '', $key, $uin)

{

    $ch = curl_init();

    $options = [

        CURLOPT_URL => $url,

        CURLOPT_HEADER => 0,//设置是否返回头信息的开关

        CURLOPT_HTTPHEADER => [

            "User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 11_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E302 MicroMessenger/6.6.6 NetType/WIFI Language/zh_CN",

            "X-WECHAT-KEY: " . $key,

            "X-WECHAT-UIN: " . $uin,

            "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",

            "Accept-Charset: UTF-8,*;q=0.5",

            "Accept-Encoding: br, gzip, deflate",

            "Accept-Language: zh-cn",

            "Cache-Control: no-cache",

            "Host: mp.weixin.qq.com",

            "Connection: keep-alive"

        ],

        CURLOPT_RETURNTRANSFER => 1,

        CURLOPT_FOLLOWLOCATION => 1,

        CURLOPT_CONNECTTIMEOUT => 5,

        CURLOPT_TIMEOUT => 60

    ];

    if ($cookie) {

        $options[CURLOPT_COOKIE] = $cookie;

}

    if ($referer) {

        $options[CURLOPT_REFERER] = $referer;

}

    curl_setopt_array($ch, $options);

    $response = curl_exec($ch);

    curl_close($ch);

    return $response;

}

控制器中的$url,是通过抓包工具抓来的。怎么抓包,我就不管了。自行百度吧。

上一篇下一篇

猜你喜欢

热点阅读