Xmeta作为最大的第三方藏品交易平台,网上有很对其进行爬取接口做藏品价格查询对比的,空闲之余,lz也写了一个,方便随时查询藏品实时价格。只是一个单文件PHP,简单易用。
1.效果展示图:
2.代码及使用
下面直接上代码,使用方式很简单,直接将你自己xmeta平台上的抓取的用户Authorization复制对应位置就行。
xm平台phpset_time_limit(0); //请求永不中断header("Content-Type: text/html; charset=utf-8");function curl_post_send($url, $params, $header)//post请求{ $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, 1);//post请求curl_setopt($ch, CURLOPT_POSTFIELDS, $params); //post请求参数 curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HttpHEADER, $header); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $return_content = curl_exec($ch); curl_close($ch); return $return_content;}function curl_get_send($url, $header) //get请求{ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $return_content = curl_exec($ch); curl_close($ch); return $return_content;}if(isset($_GET['name'])&&isset($_GET['isPresell'])){$search=$_GET['name'];$isPresell=$_GET['isPresell'];}else{$search="";$isPresell="all";}$pages=48;if(isset($_GET['pages'])){$pages=$_GET['pages'];}$s='';if($isPresell=='all'){$s='';}else if($isPresell=='sell'){$s=true;}else if($isPresell=='nosell'){$s=false;}for($i=0;$i<1;$i++){$head = array();$head[] = 'Content-Type:application/json'; //请求的Content-Type$head[]='Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJsb2bl91aWQiOjUzODI3LCJsb2dpbl91c2VyX2tleSI6Ijk0NzZiOTk3LTYxYjktNGE5OS1iMzExLTliM2YxMGE4MTkzNyJ9.e7OtfNd4pmIJF5AVDeSTmsuHqpvZtOfCM9ZrowVnzQgkcNwuKriN4oQob3Db3aAbKLF6JBKQFuLO7IeYYmWhlQ';//$url="https://api.x-metash.com/api/prod/NFTMall/h5/platform/list";//获取平台列表 。参数:{"letter":"C"}$url = "https://api.x-metash.cn/h5/home/summary"; //请求列表地址$data = [ //请求参数'search'=>$search, //搜索名称'pageSize'=>$pages,'pageNum'=>1,// 'collectionStatus'=>1, //0未销售1已销售// 'platformId'=>85, //平台id// 'minPrize'=>0, //最小价格// 'maxPrize'=>1000, //最大价格'isPresell'=>$s, //是否预售];$data = json_encode($data); //Content-Type为json配对使用$res = json_decode(curl_post_send($url,$data,$head));// var_dump($res);$data=$res->data;// var_dump($data);// foreach($data as $row){// echo "";// echo "编号uid:"https://blog.csdn.net/qq_34761385/article/details/.$row->uid." 昵称:"https://blog.csdn.net/qq_34761385/article/details/.$row->name."
";// echo "价格:"https://blog.csdn.net/qq_34761385/article/details/.$row->amount."
";// if($row->isSellOut){echo "是否销售:已出售
";}// else{ echo "是否销售:待出售
";}// echo "平台来源:"https://blog.csdn.net/qq_34761385/article/details/.$row->platfORMName."
";// echo "";// }ob_flush( );flush( );sleep( 1 );}?>
该文件也很适合二次开发,做查询信息使用!
来源地址:https://blog.csdn.net/qq_34761385/article/details/129147156
0