码上爬 第4题

<?php
$headers[]='Cookie:Hm_lvt_0d2227abf9548feda3b9cb6fddee26c0=1753770435; HMACCOUNT=6C5FAAD55F97CCBA; sessionid=igh1biz81ycba75qahqu34l4dagundyc; Hm_lpvt_0d2227abf9548feda3b9cb6fddee26c0=1753777391';
$headers[]='Referer:https://www.mashangpa.com/problem-detail/3/';
$headers[]='User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.6261.95 Safari/537.36';


$page = 1;
$time = get_total_millisecond();
$time = 1753778165113;
$sign = md5("tuling{$time}{$page}");


$url = "https://www.mashangpa.com/api/problem-detail/4/data/?page={$page}&sign={$sign}&_ts={$time}";

$code = get_curl_contents($url,$headers);
echo $url;echo $code;
$json = json_decode($code,true);
var_dump($json);




function get_total_millisecond() {
    $time = explode(" ", microtime());
    $time = ($time[1] + $time[0]) * 1000;
    $time = round($time) . '';
    return $time;
}

function get_curl_contents($bstrURL, $headers = null, $post = null) {
    $ch = curl_init($bstrURL);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    if ($headers) {
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    }
    if ($post) {
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
    }
    $data = curl_exec($ch);
    // 关闭CURL会话
    curl_close($ch);
    return $data;
}
none
最后修改于:2025年08月03日 17:08

添加新评论