<?php
header("Content-Type: text/html;charset=utf-8");
//更改id即可
for($id=130351;$id<=130452;$id++){
$url="http://www.npc.gov.cn/delegate/viewDelegate.action?dbid=".$id;
$sheng=6;
$contents = file_get_contents($url);
$contents = iconv("gb2312//IGNORE","utf-8",$contents);
$location=strpos($contents,"<TD class=bg2 rowSpan=2>")+24;
$name=substr($contents,$location,strpos(substr($contents,$location,45),"</TD>"));
//echo $name;
$contents =substr($contents,$location);
$location=strpos($contents,"<TD class=bg2>")+14;
$pro=substr($contents,$location,strpos(substr($contents,$location,30),"</TD>"));
//echo $pro;
$contents =substr($contents,$location);
$location=strpos($contents,"<TD class=bg2>")+14;
$gender=substr($contents,$location,strpos(substr($contents,$location,20),"</TD>"));
//echo $gender;
$contents =substr($contents,$location);
$location=strpos($contents,"<TD class=bg2>")+14;
$minzu=substr($contents,$location,strpos(substr($contents,$location,20),"</TD>"));
//echo $minzu;
$contents =substr($contents,$location);
$location=strpos($contents,"<TD class=bg2>")+14;
$jiguan=substr($contents,$location,strpos(substr($contents,$location,30),"</TD>"));
//echo $jiguan;
$contents =substr($contents,$location);
$location=strpos($contents,"<TD class=bg2>")+14;
$birth=substr($contents,$location,strpos(substr($contents,$location,20),"</TD>"));
//echo $birth;
$contents =substr($contents,$location);
$location=strpos($contents,"<TD class=bg2>")+14;
$dang=substr($contents,$location,strpos(substr($contents,$location,20),"</TD>"));
//echo $dang;
$contents =substr($contents,$location);
$location=strpos($contents,"<TD class=bg2_1 colSpan=3>")+30;
$zhi=trim(substr($contents,$location,strpos(substr($contents,$location,80),"</TD>")));
//echo $zhi;
$year=substr($birth,0,4);
$month=substr($birth,7,2);
if(substr($jiguan,0,$sheng)=="黑龙")$sheng=9;
if(substr($jiguan,0,$sheng)=="内蒙")$sheng=9;
$ji=substr($jiguan,0,$sheng);
$guan=substr($jiguan,$sheng);
if($dang=="民盟"){
$party="中国民主同盟";
$par="盟员";
}else if($dang=="中共"){
$party="中国共产党";
$par="党员";
}else if($dang=="民进"){
$party="中国民主促进会";
$par="会员";
}else if($dang=="九三学社"){
$party="九三学社";
$par="社员";
}else if($dang=="无"){
$party="无党派人士";
$par="";
}else if($dang=="民革"){
$party="中国国民党革命委员会";
$par="党员";
}else if($dang=="民建"){
$party="中国民主建国会";
$par="会员";
}else if($dang=="台盟"){
$party="台湾民主自治同盟";
$par="盟员";
}else if($dang=="致公党"){
$party="中国致公党";
$par="党员";
}else if($dang=="农工党"){
$party="中国农工民主党";
$par="党员";
}
$t="{{Infobox person|name=".$name."|birth_date={{birth year and age|".$year."|".$month."}}|ancestor=[[".$ji."]]";
if($guan)$t=$t."[[".$guan."]]";
$t=$t."|nationality={{CHN}}|title=[[".$zhi."]]|ethnicity=[[".$minzu."]]|gender=".$gender."|party=[[".$party."]]}}";
$t=$t."<br>'''".$name."'''({{bd|".$year."年|".strval((int)$month)."月}}),[[".$ji."]]";
if($guan)$t=$t."[[".$guan."]]";
$t=$t."人,[[".$minzu."]],[[".$party."]]".$par."。[[中华人民共和国]]政治人物、[[第十三届全国人民代表大会]][[".$pro."]]地区代表。<br><br>";
$t=$t."2018年,被选为[[".$zhi."]]{{refnest|{{Cite web|url=".$url."|title=全国人民代表大会代表信息-".$name."|accessdate=2018-03-24|work=全国人大网}}}}。<br>";
$t=$t."==參考文獻==<br>{{reflist}}<br>{{中国政治人物小作品}}<br>[[Category:第十三届全国人大代表]]<br>[[Category:";
if($guan)$t=$t.$guan;else $t=$t.$ji;
$t=$t."人]]";
if($dang!="无")$t=$t."<br>[[Category:".$party.$par."]]";
$t=$t."<br>[[Category:".substr($name,0,3)."姓]]<br><br>";
echo $t;
}