• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

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

php 搞代码 4年前 (2022-01-24) 17次浏览 已收录 0个评论

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

<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>

这是我的代码

$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);

其他的都本#文来源gaodai$ma#com搞$$代**码网$能获取到 就总分那里获取不到
——解决方案——————–

$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="#(.*?)#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]);

Array
(
[0] => 姓名:
[1] => 赵阳


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:大神改版后的四六级总分如何用正则表达式获取(旧版的小弟我会获取)
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址