关于正则表达式的问题,非常感谢!

WBOY
Release: 2016-06-23 13:34:43
Original
904 people have browsed it

以下为抓取到的页面,想通过正则表达式函数取出里边的关于教师课表安排的信息,希望各位大侠给帮忙,谢谢。
HTTP/1.1 200 OK
Connection: close
Date: Thu, 07 May 2015 07:44:28 GMT
Server: YxlinkWAF        
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
Cache-Control: private
Content-Type: text/html; charset=gb2312
Content-Length: 11062


nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


现代教学管理信息系统










<script></script>
<script> <br /> function PutSettings() <br /> { try{ <br /> factory.printing.header=""; <br /> factory.printing.footer=""; <br /> factory.printing.portrait=true; <br /> }catch(e){} <br /> <br /> } <br /> <br /> </script>



VIEWASTEXT>






<script> <br /> <!-- <br /> function __doPostBack(eventTarget, eventArgument) { <br /> var theform; <br /> if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) { <br /> theform = document.Form1; <br /> } <br /> else { <br /> theform = document.forms["Form1"]; <br /> } <br /> theform.__EVENTTARGET.value = eventTarget.split("$").join(":"); <br /> theform.__EVENTARGUMENT.value = eventArgument; <br /> theform.submit(); <br /> } <br /> // --> <br /> </script>





学年:
学期:






教师姓名:

  
  








































时间 星期一 星期二 星期三 星期四 星期五 星期六 星期日
早晨              
上午 第1节              
第2节              
第3节 线性代数B
1-17(3,4)
王黎峰
电教楼205
计科14(1)
    线性代数B
1-17(3,4)
王黎峰
电教楼205
计科14(1)
     
第4节          
下午 第5节              
第6节              
第7节              
第8节              
晚上 第9节              
第10节              










实践课(或无上课时间)信息:




课程名称 教师 学分 起止周 上课时间 上课地点 教学班组成

调、停(补)课信息:





编号 课程名称 原上课时间地点 现上课时间地点 申请时间 申请原因














回复讨论(解决方案)

里面的信息很多,请给一个期望的结果数据格式

最好把原来的链接贴出来,然后告诉期望的格式

  比如以上信息最终获取的结果是:可以取出其中的:星期一,线性代数B,1-17(3,4), 王黎峰, 电教楼205, 计科14(1);星期四,线性代数B,1-17(3,4),王黎峰,电教楼205,计科14(1)

include 'simple_html_dom.php';//这个你可以在网上下载一个$dom=new simple_html_dom();//要将内容转为 utf-8 才能处理$dom->load($content);$names=$dom->find('select[id=js]');$res=array();$res['name']=$names[0]->find('option[selected=selected]')[0]->text();$tabletr=$dom->find('table[id=Table6] tr');foreach($tabletr as $k=>$tr){	foreach($tr->find('td') as $k1=>$td){		if($k1!==0){			$info[$k][$k1]=$td->text();		}	}}//优化数据foreach($info as $k=>$v){	if($k==1){		unset($info[1]);	}	if(count($v)==8){		unset($v[1]);	}	$info[$k]=array_values($v);}$week=$info[0];unset($info[0]);//组织数据foreach($info as $v){	foreach($v as $k=>$v){		$tmp[$week[$k]][]=$v;	}}$res['info']=$tmp;echo "<pre class="brush:php;toolbar:false">";print_r($res);echo "
Copy after login
";/*Array( [name] => 王峰 [info] => Array ( [星期一] => Array ( [0] => [1] => [2] => 线性代数B1-17(3,4)王黎峰电教楼205计科14(1) [3] => [4] => [5] => [6] => [7] => [8] => [9] => [10] => ) [星期二] => Array ( [0] => [1] => [2] => [3] => [4] => [5] => [6] => [7] => [8] => [9] => [10] => ) [星期三] => Array ( [0] => [1] => [2] => [3] => [4] => [5] => [6] => [7] => [8] => [9] => [10] => ) [星期四] => Array ( [0] => [1] => [2] => 线性代数B1-17(3,4)王黎峰电教楼205计科14(1) [3] => [4] => [5] => [6] => [7] => [8] => [9] => [10] => ) [星期五] => Array ( [0] => [1] => [2] => [3] => [4] => [5] => [6] => [7] => [8] => [9] => [10] => ) [星期六] => Array ( [0] => [1] => [2] => [3] => [4] => [5] => [6] => [7] => [8] => [9] => ) [星期日] => Array ( [0] => [1] => [2] => [3] => [4] => [5] => [6] => [7] => [8] => [9] => ) ))*///根据你自己的需求来处理课程信息$txt = <<
";print_r($arr);echo "
Copy after login
";

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template