<?php
/**
* FILE_NAME:index.php
* PHP+MySQL采集ICP网站备案系统
*
* @copyright Copyright (c) 2011-2015 www.phpwebgo.com
* @author phpwebgo@gmail.com
* @package core
* @version 2011-1-11 下午03:25:55
*/
header("Content-type:text/html;charset=utf-8");
include_once("conn.php");
$id=(int)$_GET['id']?(int)$_GET['id']:"1";
if($id<=5269289 && $id){
set_time_limit(0);
$con=@file_get_contents("http://www.miibeian.gov.cn/icp/publish/query/icpMemoInfo_login.action?id=".$id."");
$con=iconv("GBK","utf-8",$con);//echo $con;
$tmp = "/<tr.*>(.*)</tr>/iUs";
preg_match_all ( $tmp, $con, $macthes ); //print_r($macthes);die;
$tmp = "/<td.*>(.*)</td>/iUs";
$arr = Array ();
foreach ( $macthes [1] as $tr ) {
preg_match_all ( $tmp, $tr, $td );
$arr [] = $td [1];
}
//print_r($arr);die;
$a = trim(strip_tags(str_replace ( " ", "", $arr[1][2])));
$a2 = trim(strip_tags(str_replace ( " ", "", $arr[1][4])));
$a3 = trim(strip_tags(str_replace ( " ", "", $arr[2][1])));
$a4 = trim(strip_tags(str_replace ( " ", "", $arr[2][3])));
$a5 = trim(strip_tags(str_replace ( " ", "", $arr[6][2])));
$a6 = trim(strip_tags(str_replace ( " ", "", $arr[6][4])));
$a7 = trim(strip_tags(str_replace ( " ", "", $arr[7][1])));
$a8 = trim(strip_tags(str_replace ( " ", "", $arr[7][3])));
$a9 = trim(strip_tags(str_replace ( " ", "", $arr[8][1])));
$a10= trim(strip_tags(str_replace ( " ", "", $arr[8][3])));
echo $a."<hr>";
echo $a2."<hr>";
echo $a3."<hr>";
echo $a4."<hr>";
echo $a5."<hr>";
echo $a6."<hr>";
echo $a7."<hr>";
echo $a8."<hr>";
echo $a9."<hr>";
echo $a10."<hr>";
if($a){
$intosql="INSERT INTO beian (`ipcxkzh` ,`passtime` ,`zbdwmc` ,`zbdwxz` ,`sitename` ,`siteurl` ,`siteower` ,`siteym` ,`siteba` ,`qzspx`) VALUES ('$a','$a2','$a3','$a4','$a5','$a6','$a7','$a8','$a9','$a10')";//echo $intosql;die;
mysql_query($intosql);
}
sleep(2);//可以注释掉
$id++;
echo "正在采集......".$id;
echo "<script>location.href='index.php?id=".$id."'</script>";
}else{
echo "采集结束";
}
?>
Categories: PHP编程




