php版:
<?php
$ua=$_SERVER['HTTP_USER_AGENT'];
$ua=strtolower($ua);
if($ua!="" &&strpos($ua,"baiduspider")){
if(strpos($ua,"android") || strpos($ua,"mobile")){
echo "是百度移动UA";
}else{
echo "是百度PCUA";
}
}else{
echo"不是baiduspider UA";
}
?>
asp版:
<%
ua=Request.ServerVariables("HTTP_USER_AGENT")
ua=LCase(ua)
if ua<>"" andInStr(ua,"baiduspider")<>0 then
ifInStr(ua,"android")<>0 or InStr(ua,"mobile")<>0then
response.write "是百度移动 UA"
else
response.write"是百度PC UA"
endif
else
response.write "不是baiduspiderUA"
end if
%>