xmeta二手交易查询php网页版

文章介绍了一个使用PHP编写的简单脚本,该脚本用于爬取Xmeta平台的藏品价格信息,支持实时查询和筛选功能,便于用户监控藏品市场动态。代码包括GET和POST请求函数,以及页面交互处理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Xmeta作为最大的第三方藏品交易平台,网上有很对其进行爬取接口做藏品价格查询对比的,空闲之余,lz也写了一个,方便随时查询藏品实时价格。只是一个单文件php,简单易用。

1.效果展示图:

2.代码及使用

下面直接上代码,使用方式很简单,直接将你自己xmeta平台上的抓取的用户Authorization复制对应位置就行。


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>xm平台</title>
</head>
<body>

<?php
	
	set_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;
	}
	
	/**
	 *url:https://api.x-metash.com/api/prod/NFTMall/h5/sendCode    {"phone":"19180363828"}  发送验证码
	 *url:https://api.x-metash.com/api/prod/NFTMall/h5/login   {"phone":"19180363828","code":"721871","city":"未知","headImg":"https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTJytplhw6kvdsT09icr9kIAIw0VKx69pIZm4qQeTv8FjR16WyCMUOjPqD7VlPU5FHlVjchVLlZrjhQ/132","nickName":"劉衿","openid":"oBpb35zENB5DjLxaVSzAD-Z6bhJQ","province":"未知","sex":0}
	 ***/
	
	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  "<img  style='width:220px;height:120px' src=".$row->img.">";
		// 	echo  "<p>编号uid:".$row->uid."  昵称:".$row->name."</p>";
		// 	echo  "<p>价格:".$row->amount."</p>";
		// 	if($row->isSellOut){echo "<p>是否销售:<span style='color:red'>已出售</span></p>";}
		// 	else{ echo "<p>是否销售:<span style='color:green'>待出售</span></p>";}
		// 	echo "<p>平台来源:".$row->platformName."</p>";
		// 	echo "</br>";
		// }
		ob_flush( );
		flush( );
		sleep( 1 );
	}
?>

<!-- main start -->

<div id="yhc_responsive" class="main">
    <div class="allProduct respl-header">
        <ul class="productTab respl-option" data-option-key="filter">
			<div style="display: inline-block;float: left;">
				<input type="text" id="in" value="<?php echo $search ?>" />
				<input type="button" id="btn" value="搜索" />
			</div>
			
            <li data-type="all"   <?php if($isPresell=='all') echo "class='select'"; ?>   ><a href="#" data-rl_value="*">全部</a></li>
            <li data-type='sell' <?php if($isPresell=='sell') echo "class='select'"; ?>><a href="#" data-rl_value=".category-10" >待售</a></li>
            <li data-type='nosell' <?php if($isPresell=='nosell') echo "class='select'"; ?> ><a href="#" data-rl_value=".category-20" >预售</a></li>
        </ul>
        <ul class="ProductList respl-items">
			<?php foreach($data as $row){?>
            <li class="respl-item category-10">
                <div class="unit">
                    <p class="hoverline"></p>
                    <div class="images"><img src="<?php echo $row->img ?>"></div>
                    <h1><?php echo $row->name ?></h1>
                    <dl>
                    <?php if($row->isSellOut){echo "<dd>状态:<span style='color:red'>已出售</span></dd>";}
                        else{ echo "<dd>状态:<span style='color:green'>待出售</span></dd>";} ?>
                        <dd style="color: red">价格:<?php echo $row->amount ?></dd>
                        <dd>平台来源:<?php echo $row->platformName ?></dd>
                    </dl>
                </div>
            </li>
			<?php } ?>
        </ul>
    </div>   
</div>

<!-- main end -->

<!-- load more -->
<div class="loadMore">
	<a href="javascript:;" onclick="getmore()">更多</a>
</div>
</body>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
<script>
	if(!window.sessionStorage.getItem('num')){
		window.sessionStorage.setItem('num',48);
	}
	function getmore(){
		var num=window.sessionStorage.getItem('num');
		console.log(num)
		var n=Number(num)+Number(12);
		num=n;
		window.sessionStorage.setItem('num',num);
		
		var name = $("#in").val();
		var type="<?php echo $isPresell ?>";
		var url=window.location.pathname+"?pages="+n+"&name="+name+"&isPresell="+type;
		$.ajax({url:url,success:function(result){
		    $("html").html(result);
		}});
	}
	
	$("#btn").click(function(){
		var name = $("#in").val();
		var type="<?php echo $isPresell ?>";
		var url=window.location.pathname+"?name="+name+"&isPresell="+type;
		$.ajax({url:url,success:function(result){
		    $("html").html(result);
		}});
	})
	
	$("li").click(function(){
		// console.log($(this).data('type'));
		var type=$(this).data('type');
		$(this).siblings().removeClass('select');
		$(this).addClass('select');
		var name = $("#in").val();
		var url=window.location.pathname+"?name="+name+"&isPresell="+type;
		$.ajax({url:url,success:function(result){
		    $("html").html(result);
		}});
		// window.location.href=window.location.pathname+"?name=乾坤&isPresell="+type;
	})
</script>
<style>
	#in{
		padding: 5px;
		width: 200px !important;
		border: 1px solid #ccc;
		border-radius: 3px;
		    width: 100%;
		    box-sizing: border-box;
		    font-family: montserrat;
		    color: #2c3e50;
		    font-size: 13px;
	}
	#btn{
		width: 100px;
		    background: #ff9a76;
		    font-weight: bold;
		    color: #fff;
		    transition: 150ms;
		    border: 0 none;
		    border-radius: 12px;
		    cursor: pointer;
		    padding: 1px 5px;
			height: 28px;
	}
	
	@charset "utf-8";
	/* CSS reset */
	body,div,ul,ol,li,dl,dt,dd,p,h1,h2,h3,h4,h5,h6,select,option,td,th,form,fieldset,input,textarea{padding:0;margin:0;}
	table{border-collapse:collapse;border-spacing:0;}
	fieldset,img{border:none;}
	address,em,th{font-style:normal;font-weight:normal;}
	caption,th{text-align:left;}
	ol,ul{list-style:none outside none;}
	h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}
	body{font:12px/1.6em "\5B8B\4F53";color:#838383;}
	/* Global style */
	.clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden;}
	.clearfix{zoom:1;}
	a:link,a:visited{text-decoration:none;color:#838383;}
	.left{float:left;}
	.right{float:right;}
	
	/* main */
	.main{width:1200px;margin:50px auto;padding:28px 0;}
	
	.ProductList{overflow:hidden;}
	.ProductList li{float:left;margin-right:42px;width:268px;height:340px;background-color:#FAFAFA;overflow:hidden;}
	.ProductList .unit{position:relative;z-index:4;height:340px;}
	.ProductList .hoverline{display:none;height:4px;width:100%;background-color:#C68D43;position:absolute;top:0;left:0;}
	.ProductList .images{display:block;height:222px;width:268px;overflow:hidden;}
	.ProductList .images img{display:block;max-height:222px;width:268px;}
	.ProductList h1{text-align:center;padding-top:6px;}
	.ProductList dl{padding:4px 10px 10px 30px;}
	.ProductList dd{white-space:nowrap;overflow:hidden;height:26px;line-height:26px;}
	.view{position:absolute;z-index:500;left:0;bottom:-60px;width:100%;height:59px;background-color:#FAFAFA;font-size:14px;font-family:"\5FAE\8F6F\96C5\9ED1";border-bottom:1px solid #C68D43;}
	.view .left{padding-left:30px;}
	.view .right{background-color:#C68D43;color:#fff;display:block;height:30px;line-height:30px;width:80px;text-align:center;}
	.view .right span{font-family:"\5B8B\4F53";font-size:16px;padding-left:6px;}
	.view .right:hover{background-color:#2D2D2D;}
	
	/* allProduct */
	.allProduct{position:relative;z-index:2;}
	.productTab{position:absolute;top:-68px;right:0;height:32px;padding-top:8px;z-index:9999;display: flex;align-items: center;}
	.productTab li{margin-bottom: 0 !important;float:left;color:#fff;background-color:#c68d43;margin-left:20px;height:24px;line-height:24px;font-family:"\5B8B\4F53";font-size:14px;border-radius:14px;}
	.productTab li:hover{background-color:#2d2d2d;}
	.productTab li.select{background-color:#2d2d2d;}
	.productTab  a{display:block;color:#fff;padding:0 30px;border-radius:14px;}
	.allProduct .ProductList{width:1240px;}
	.allProduct li{margin-bottom:20px;}
	.loadMore{width:100%;height:40px;border-top:1px solid #C68D43;position:relative;z-index:2;}
	.loadMore a{position:absolute;height:40px;line-height:40px;text-align:center;width:140px;color:#fff;background-color:#C68D43;left:45%;top:-20px;font-size:14px;}
	.loadMore a:hover{background-color:#2d2d2d;}
	
	/* isotope */
	.isotope-item{z-index:2}
	.isotope-hidden.isotope-item{pointer-events:none;z-index:1}
	.isotope,.isotope .isotope-item{
		-webkit-transition-duration:0.8s;
		-moz-transition-duration:0.8s;
		-ms-transition-duration:0.8s;
		-o-transition-duration:0.8s;
		transition-duration:0.8s
	}
	.isotope{
		-webkit-transition-property:height, width;
		-moz-transition-property:height, width;
		-ms-transition-property:height, width;
		-o-transition-property:height, width;
		transition-property:height, width
	}
	.isotope .isotope-item{
		-webkit-transition-property:
		-webkit-transform, opacity;
		-moz-transition-property:-moz-transform, opacity;
		-ms-transition-property: -ms-transform, opacity;
		-o-transition-property:top, left, opacity;
		transition-property:transform, opacity
	}
	.isotope.no-transition,.isotope.no-transition .isotope-item,.isotope .isotope-item.no-transition{
		-webkit-transition-duration:0s;
		-moz-transition-duration:0s;
		-ms-transition-duration:0s;
		-o-transition-duration:0s;
		transition-duration:0s
	}
</style>
</html>



该文件也很适合二次开发,做查询信息使用!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

流情

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值