汽车违章查询

汽车违章查询是通过其他网站的页面来完成的,这里可以对其进行加工处理,这里仅提供一种思路的参考。

该页面可对郑州市的车辆进行违章查询,使用时请正确改正车牌号VIN码,本处直接写死,且是错误的~~~

其他地区能否使用,没有测试,可能不行,特此说明~~~

default.php的源代码:

<!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>汽车违章查询</title>
<style type="text/css">
table{ border:3px double red; border-collapse:collapse; }
td{ border:1px solid white;  font-size:12px; padding:8px;}
img { float:left; border:none;}
#yzm{ margin:0 3px; padding:2px; height:16px; }
div { padding:10px; }
</style>
<script type="text/javascript" src="js/jquery.js" ></script>
<script type="text/javascript">
$(function(){
	$('#query').click(function(){
		$.post("6.php?id=<?php print $_GET["id"] ?>", { 'yzm': $('#yzm').val() }, function(d){ 
			$('#result').html(d); 


		});
	});	
});
</script>
</head>


<body>
<img src="5.php"  /><input id="yzm" type="text" /><input id='query' type="button" value=" 查询 " />
<div id='result'></div>
</body>
</html>



5.php的源代码:

<?php
session_start();
if(isset($_SESSION["tmpFile"])){
	$cookie=$_SESSION["tmpFile"];
}
else{
	$cookie = tempnam('./tmp','cb'); 
	$_SESSION["tmpFile"]=$cookie;
}
$url='http://www.ha114.net/zxywbl/GetYzmCode.aspx';
$ch = curl_init();//初始化curl  
curl_setopt($ch,CURLOPT_URL, $url);//提交到指定网页  
curl_setopt($ch,CURLOPT_HEADER,0); //header头部信息
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上  
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie); 
$img=curl_exec($ch);
curl_close($ch); 
header("Content-type: image/jpg");
echo $img;
?>

6.php的源代码:

<?php
session_start();
function getHtml($url,$tmpFile,$postData)
{
	$ch = curl_init($url);
	curl_setopt($ch,CURLOPT_HEADER,0);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
	curl_setopt($ch, CURLOPT_COOKIEJAR, $tmpFile);
	curl_setopt($ch, CURLOPT_COOKIEFILE, $tmpFile); 
	if($postData!=NULL)
	{
		curl_setopt($ch, CURLOPT_POST, 1);  
		curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); 
	}
	$content=curl_exec($ch);  
	curl_close($ch); 
	return $content;
}	
?>
<?php
header("Content-type:text/html;charset=utf-8");


!empty($_SESSION["tmpFile"]) or die( "该页面不能直接访问~~~");
$tmpFile=$_SESSION["tmpFile"];
file_exists($tmpFile) or die('状态文件被删除,无法进一步操作~~~');
$url='http://www.ha114.net/zxywbl/jdc_cx.aspx?ywdm=A_1';
$content=getHtml($url,$tmpFile,NULL);
preg_match('/id="__VIEWSTATE" value="([^"]+)"/', $content, $matches);
$yzm=$_POST["yzm"];
$id=$_GET["id"];
$idInt=(int)$id;
if( "$idInt"!=$id ) die("格式错误~~~");
$user='root';
$pass='3237';
$db = new PDO('mysql:host=localhost;dbname=db', $user, $pass);
$db->query("set names utf8");
$rs = $db->query("SELECT * FROM CARS where id=$id");
$arr = $rs->fetchAll();
if(count($arr)==1)
{
	$h=$arr[0]['h'];
	$vin=$arr[0]['vin'];
	$xm=$arr[0]['xm'];
	$postArray = array(
		'__VIEWSTATE'=>urlencode($matches[1]),
		'ddlHpzl'=>'02',
		'txtHphm'=> urlencode($h),//车牌号
		'txtClsbdh'=>$vin,
		'txtYzm'=>$yzm,
		'Button1'=>'+%E6%9F%A5%E3%80%80%E8%AF%A2+'	// ' 查 询 '
	);
	foreach($postArray as $key=>$value) { $postData .= $key.'='.$value.'&'; }
	rtrim($postData,'&');
	$content=getHtml($url,$tmpFile,$postData);
	//$content=preg_replace('/<div id="Panel1">(.*)<\/div>/','',$content);
	preg_match('/<div id="Panel\d">(.*)<\/div>/is', $content, $matches);
	//$content=preg_replace('/</','<',$matches[1]);
	$content=$matches[1];
	print $content;
}
else
{
	print '没有找到相关信息~~~';
}
//unlink($tmpFile);
?>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值