1 回答

TA貢獻1828條經(jīng)驗 獲得超13個贊
隨機猜測后,我發(fā)現(xiàn)如果您不提供 User-Agent 標頭,指定的 API 將不會返回任何項目。
這是我的版本:
<?php
$eop = 0;
$newest = 0;
while($eop == 0) {
$url='https://shopee.ph/api/v2/search_items/?by=ctime&limit=30&match_id=49133756&newest=0&order=desc&page_type=shop&version=2';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36"));
$response = curl_exec($ch);
$http = curl_getinfo($ch, CURLINFO_HTTP_CODE);
print_r($response);
curl_close($ch);
if ($http == 200) {
$products = json_decode($response, TRUE);
$items = $products['items'];
if (count($items) > 1 ) {
foreach ($items as $item) {
$id = $item['itemid'];
echo $id . '<br>';
}
} else {
$eop=1;
}
}
$newest = $newest + 30;
}
- 1 回答
- 0 關(guān)注
- 103 瀏覽
添加回答
舉報