Charles 抓取百度指数及微信指数

发布时间 2023-10-25 10:48:13作者: 佚小名

一、百度指数

 

 

filter:/api/SearchApi/index //搜索指数

 

filter:/api/SearchApi/index //搜索指数

 找到uniqid,继续filter,获取data(用于解密)

 

 filter: api/SearchApi/index ,获取对应指数数据用于解密,页面控制台解密:

 解密代码

function decrypt (t, e) {
    if (!t)
        return "";
    for (var a = t.split(""), n = e.split(""), i = {}, r = [], o = 0; o < a.length / 2; o++)
        i[a[o]] = a[a.length / 2 + o];
    for (var s = 0; s < e.length; s++)
        r.push(i[n[s]]);
    return r.join("")
}


resp  = decrypt("%no,MgmqS5cI2PV27-9.830+1564%,","5ncV5gIV52qV5%gVIIVInVI5VInVc,VIIV5%2V5%2V5c2V5I,V5cmV5IIV%qIV5cgV5cgVI,V52%V5c,V5gIV5cnV52mV5mmV5m,V525V5ccV5c2")
console.log(resp)

 二、微信指数

filter:wxaweb/wxindex

  

 

 

选中连接右键选择copy curl request

curl -H "Host: search.weixin.qq.com" -H "xweb_xhr: 1" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x6309071d)XWEB/8461" -H "Content-Type: application/json" -H "Accept: */*" -H "Sec-Fetch-Site: cross-site" -H "Sec-Fetch-Mode: cors" -H "Sec-Fetch-Dest: empty" -H "Referer: https://servicewechat.com/wxc026e7662ec26a3a/43/page-frame.html" -H "Accept-Language: zh-CN,zh;q=0.9" --data-binary "{\"openid\":\"ov4ns0FDBHu62yON4EUkflFa49Gw\",\"search_key\":\"1698200592895285_1665915831\",\"cgi_name\":\"GetDefaultIndex\",\"query\":[\"瀹佸痉鏃朵唬\"],\"start_ymd\":\"20221025\",\"end_ymd\":\"20231025\"}" --compressed "https://search.weixin.qq.com/cgi-bin/wxaweb/wxindex"

 通过gpt转为PHP代码并导出:

//微信指数
    public function wechat_scroe()
    {
        $name='宁德时代';
        $url = 'https://search.weixin.qq.com/cgi-bin/wxaweb/wxindex';
        $data = array(
            'openid' => 'ov4ns0FDBHu62yON4EU',
            'search_key' => '1698137976699775_3211130377',
            'cgi_name' => 'GetDefaultIndex',
            'query' => array('宁德时代'),
            'start_ymd' => '20211023',
            'end_ymd' => '20231024'
        );
        $headers = array(
            'Host: search.weixin.qq.com',
            'xweb_xhr: 1',
            'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090719)XWEB/8461',
            'Content-Type: application/json',
            'Accept: */*',
            'Sec-Fetch-Site: cross-site',
            'Sec-Fetch-Mode: cors',
            'Sec-Fetch-Dest: empty',
            'Referer: https://servicewechat.com/wxc026e7662ec26a3a/43/page-frame.html',
            'Accept-Language: zh-CN,zh;q=0.9'
        );

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $result = curl_exec($ch);
        curl_close($ch);
        $file_path=storage_path() . '/file/'.$name.'微信指数.json';
        file_put_contents($file_path,$result);
        $data=file_get_contents($file_path);
        $data=json_decode($data,true);
        $data=$data['content']['resp_list'][0]['indexes'][0]['time_indexes'];
        app(\App\Http\Controllers\FileController::class)->export($data,$name);
        dd($result);

    }

  

public  function export($data,$fileName){
        
        $spreadsheet = new Spreadsheet();
        $sheet       = $spreadsheet->getActiveSheet();
        //设置工作表标题名称
        $sheet->setTitle($fileName);
        $row=2;
        $sheet->setCellValueExplicitByColumnAndRow(1, 1, '时间', DataType::TYPE_STRING);
        $sheet->setCellValueExplicitByColumnAndRow(2, 1, '指数', DataType::TYPE_STRING);
        foreach ($data as $key => $value) {
            // dd($value);
            $value['score']=number_format($value['score'],0, '.', ',');
            $sheet->setCellValueExplicitByColumnAndRow(1, $row, $value['time'], DataType::TYPE_STRING);
            $sheet->setCellValueExplicitByColumnAndRow(2, $row, $value['score'], DataType::TYPE_STRING);
            $row++;

        }

        $file_path = storage_path() . '/file/' . $fileName . ".xlsx";
        $writer    = IOFactory::createWriter($spreadsheet, 'Xlsx');
        //这里可以写绝对路径,其他框架到这步就结束了
        $writer->save($file_path);
        //关闭连接,销毁变量
        $spreadsheet->disconnectWorksheets();
        unset($spreadsheet);
    }