Home > Backend Development > PHP Tutorial > 大神改版后的四六级总分如何用正则表达式获取(旧版的小弟我会获取)

大神改版后的四六级总分如何用正则表达式获取(旧版的小弟我会获取)

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 11:55:29
Original
994 people have browsed it

请教各位大神改版后的四六级总分怎么用正则表达式获取(旧版的我会获取)
这是四六级网站

<table border="0" align="center" cellpadding="0" cellspacing="6" class="cetTable"><br />	<tr><br />		<th>姓名:</th><br />		<td>赵阳</td><br />	</tr><br />	<tr><br />		<th>学校:</th><br />		<td>长春中医药大学</td><br />	</tr><br />	<tr><br />		<th>考试类别:</th><br />		<td>英语四级</td><br />	</tr><br />	<tr><br />		<th>准考证号:</th><br />		<td>220090132112529</td><br />	</tr><br />	<tr><br />		<th>考试时间:</th><br />		<td>2013年12月</td><br />	</tr><br />	<tr><br />		<th valign="top">总分:</th><br />		<td valign="top" class="fontBold"><br />        <span class="colorRed"><br />		<br />			0<br />		<br />        </span><br />		<br />        	<br /><span class="color666">听力:</span><br />			<br />				000<br />			<br />            <br /><span class="color666">阅读:</span><br />			<br />			000<br />			<br />			<br />            <br /><span class="color666">写作与翻译:</span><br />			<br />			000<br />			<br />		</td><br />	</tr><br /></table>
Copy after login

这是我的代码
$a = curl_exec($ch);<br />			$match="#<td>(.*)</td>#";<br />			//$match="#<span>(.*)</span>#";<br />preg_match_all($match,$a,$b);<br />$yourname= $b[1][0];<br />$school= $b[1][1];<br />$cet= $b[1][2];<br />$c= $b[1][5];//分数<br />$score=strip_tags($c);<br />$score=str_replace(" ","",$score);  <br />		return array('school'=>$school,'name'=>$yourname,'cet'=>$cet,'score'=>$score);
Copy after login

其他的都能获取到 就总分那里获取不到
------解决方案--------------------
$a =<<< TXT<br /><table border="0" align="center" cellpadding="0" cellspacing="6" class="cetTable"><br />    <tr><br />        <th>姓名:</th><br />        <td>赵阳</td><br />    </tr><br />    <tr><br />        <th>学校:</th><br />        <td>长春中医药大学</td><br />    </tr><br />    <tr><br />        <th>考试类别:</th><br />        <td>英语四级</td><br />    </tr><br />    <tr><br />        <th>准考证号:</th><br />        <td>220090132112529</td><br />    </tr><br />    <tr><br />        <th>考试时间:</th><br />        <td>2013年12月</td><br />    </tr><br />    <tr><br />        <th valign="top">总分:</th><br />        <td valign="top" class="fontBold"><br />        <span class="colorRed"><br />         <br />            0<br />         <br />        </span><br />         <br />            <br /><span class="color666">听力:</span><br />             <br />                000<br />             <br />            <br /><span class="color666">阅读:</span><br />             <br />            000<br />             <br />             <br />            <br /><span class="color666">写作与翻译:</span><br />             <br />            000<br />             <br />        </td><br />    </tr><br /></table><br />TXT;<br />$match="#<t[hd].*?>(.*?)</t[hd]>#is";<br />preg_match_all($match,$a,$b);<br />$b[1][11] = preg_replace('/\s/', '', strip_tags($b[1][11]));<br />print_r($b[1]);
Copy after login
Array
(
    [0] => 姓名:
    [1] => 赵阳

Related labels:
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template