php获取抖⾳xgorgon,爬取抖⾳数据,可以直接调⽤的抖⾳接⼝因为php是⼗分流⾏的web编程语⾔,因此⽤php写了⼀个抓取抖⾳⽤户数据的程序。
aweme_id=6816607819614145804,这个是不同的视频id
失落非主流cursor=20 这个是数据分页,每次分页加20
返回的utf8格式的json数据。所有的数据都在⾥⾯,需要什么取什么。这⾥直接⽤360浏览器打开截图:
php代码:
getDyCom.php
header("Conten-type:text/html;charset=utf-8");
require "getGorgon.php";
if(@$_GET["aweme_id"]==""){
$aweme_id="6816607819614145804";//视频id
}else{
$aweme_id=$_GET["aweme_id"];
}
if(@$_GET["cursor"]==""){
$cursor=0;//分页,每次加20条
}else{
$cursor=$_GET["cursor"];
}
$ts=floor(getMillisecond()/1000);
鹿晗镶钻七龙珠$_rticket=getMillisecond();
$cookie='odin_tt=d296eed92fc94190097ef3311b590355d87d4938a3c0a03fb1f7951d49d330dac7d22ee338409924bb57f11c59523f0a3b243e126d32aafef c77a1054088dc57; uid_tt=a1f7f2b0aefb7e6f10658083ca2bfb8f; uid_tt_ss=a1f7f2b0aefb7e6f10658083ca2bfb8f; sid_tt=861d0d1876038df131e0fd31895e7 a7e; sessionid=861d0d1876038df131e0fd31895e7a7e; sessionid_ss=861d0d1876038df131e0fd31895e7a7e; install_id=111883427372; ttreq=1$ed9b9ef0 b79f17bb4439d40deb5bd0e839a6406d; sid_guard=861d0d1876038df131e0fd31895e7a7e%7C1587288582%7C5184000%7CThu%2C+18-Jun-2020+09 %3A29%3A42+GMT; SLARDAR_WEB_ID=08c83f7f-e42a-4454-a8db-21c62112d6e9';
lol战队名字$url = 'aweme-hl.snssdk/aweme/v2/comment/list/?aweme_id='.$aweme_id.'&cursor='.$c通俗唱法的特点
ursor.'&count=20&address_book_access=1&gps_acce ss=1&forward_page_type=1&channel_id=0&city=610700&hotsoon_filtered_count=0&hotsoon_has_more=0&os_api=22&device_type=HUAWEI%20MLA-AL 10&ssmix=a&manifest_version_code=100501&dpi=240&uuid=863064010762377&app_name=aweme&version_name=10.5.0&ts='.$ts.'&app_type=normal &ac=wifi&update_version_code=10509900&channel=aweGW&_rticket='.$_rticket.'&device_platform=android&iid=111883427372&version_code=100500&c did=36db7bfc-b670-4fa8-815f-6a352b973cd1&openudid=4cedfb75190b8733&device_id=69244350688&resolution=720*1280&os_version=5.1.1&language =zh&device_brand=HUAWEI&aid=1128&mcc_mnc=46007';
$gorgon=getXg($url,$cookie,$ts,$_rticket);
$headers[] = "Host:aweme-hl.snssdk";
$headers[] = "Connection: keep-alive";
$headers[] = 'Cookie: '.$cookie;
$headers[] = "X-SS-REQ-TICKET: 1588555815435";
$headers[] = "X-Tt-Token: 00861d0d1876038df131e0fd31895e7a7ec84405d255864de8fb1c72cfba
5b43f47abc1d13178401d7eccc11394ed2d84755"; $headers[] = "sdk-version: 1";
$headers[] = "x-tt-trace-id: 00-dd4e1bf00a101f48f0e0fa15bc950468-dd4e1bf00a101f48-01";
$headers[] = "User-Agent: com.ss.android.ugc.aweme/100501 (Linux; U; Android 5.1.1; zh_CN; HUAWEI MLA-AL10; Build/HUAWEIMLA-AL10; Cronet/TT NetVersion:3154e555 2020-03-04 QuicVersion:8fc8a2f3 2020-03-02)";
陈都灵男友$headers[] = "X-Gorgon: ".$gorgon;
$headers[] = "X-Khronos: ".$ts;
$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,$url);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl, CURLOPT_HTTPHEADER,$headers);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
$data = curl_exec($curl);
echo $data;
curl_close($curl);
>
获取x-gorgon的代码
getGorgon.php
function getXg($url,$cookie,$ts,$_rticket){
$headers[] = "Connection: keep-alive";
$headers[] = "Content-Type: application/x-www-form-urlencoded;charset=utf-8"; $post_url='47.107.249.230:8080/mydouyin/servlet/GetGorgon';
$post_data = array(
'url'=>$url,
'cookie'=>$cookie,
'ts'=>$ts,
'_rticket'=>$_rticket
);
$post_data = http_build_query($post_data);
$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,$post_url);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl, CURLOPT_HTTPHEADER,$headers);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
$data = curl_exec($curl);
curl_close($curl);
return $data;
}
function getMillisecond() {
list($t1, $t2) = explode(' ', microtime());
卡姆女友return (float)sprintf('%.0f',(floatval($t1)+floatval($t2))*1000);
}
>
以上仅为学习交流⽤
我的v:lb87626
发布评论