Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial 使用crul抓取内容的时候。

使用crul抓取内容的时候。

Jun 23, 2016 pm 02:18 PM

使用crul抓取内容的时候。我发现如果截取的内容少。能正常输入。一旦截取的内容多。就只显示Array();了。。这是为什么。。还有就是我要抓取的是表格。中的某一项。没特征。。求思路~~~


回复讨论(解决方案)

建议把你的代码贴出来以供分析

<html>	<head>		<title></title><link href="/css/newcss/project.css" rel="stylesheet" type="text/css">	</head>	<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" style="overflow:auto;">		<form name="form" method="post"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td class="Linetop"></td></tr></table><table width="100%"  border="0" cellpadding="0" cellspacing="0" class="title" id="tblHead"><tr>					<td width="80%" >					<table border="0" align="left" cellpadding="0" cellspacing="0" >										<tr>					<td> </td>					<td valign="middle"> <b>本学期成绩查询列表</b>					 </td>					</tr>					</table>					</td>					<td width="20%" >											<table border="0" align="left" cellpadding="0" cellspacing="0" width="100%" >												<tr>						<td> </td>											<td width="5"></td>					</tr>					</table>					</td>					</tr></table><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td class="Linetop"></td></tr></table>			<table width="100%" border="0" cellpadding="0" cellspacing="0" class="titleTop2">					 <tr>					  <td class="pageAlign">					   <table cellpadding="0" width="100%" class="displayTag" cellspacing="1" border="0" id="user">					    <thead>							<tr>					<th align="center" width="10%" class="sortable">						课程号					</th>					<th align="center" width="10%" class="sortable">						课序号					</th>					<th align="center" width="20%" class="sortable">						课程名					</th>					<th align="center" width="20%" class="sortable">						英文课程名					</th>					<th align="center" width="10%" class="sortable">						学分					</th>					<th align="center" width="10%" class="sortable">						课程属性					</th>					<th align="center" width="10%" class="sortable">成绩					</th>				</tr>															<tr class="odd" onMouseOut="this.className='even';" onMouseOver="this.className='evenfocus';">							<td align="center">								00002473							</td>							<td align="center">								26								</td>							<td align="center">								形势与政策(六)							</td>							<td align="center">								Situation and Policy (Ⅵ)							</td>							<td align="center">								0							</td>							<td align="center">								综合必修							</td>							<td align="center">													 	    </td>						</tr>											<tr class="odd" onMouseOut="this.className='even';" onMouseOver="this.className='evenfocus';">							<td align="center">								00002435							</td>							<td align="center">								09								</td>							<td align="center">								文献检索与利用A							</td>							<td align="center">								Literature Retrieval and Utilization A							</td>							<td align="center">								2							</td>							<td align="center">								综合必修							</td>							<td align="center">													 	    </td>						</tr>											<tr class="odd" onMouseOut="this.className='even';" onMouseOver="this.className='evenfocus';">							<td align="center">								00000406							</td>							<td align="center">								09								</td>							<td align="center">								软件工程导论							</td>							<td align="center">								Introduction to Software Engineering							</td>							<td align="center">								3							</td>							<td align="center">								专业必修							</td>							<td align="center">													 	    </td>						</tr>											<tr class="odd" onMouseOut="this.className='even';" onMouseOver="this.className='evenfocus';">							<td align="center">								00001017							</td>							<td align="center">								01								</td>							<td align="center">								软件代码开发技术							</td>							<td align="center">								Development Technology for Software Coding							</td>							<td align="center">								2.5							</td>							<td align="center">								专业选修							</td>							<td align="center">													 	    </td>						</tr>											<tr class="odd" onMouseOut="this.className='even';" onMouseOver="this.className='evenfocus';">							<td align="center">								00000995							</td>							<td align="center">								01								</td>							<td align="center">								编译原理A							</td>							<td align="center">								The Principle of Compiler A							</td>							<td align="center">								3							</td>							<td align="center">								专业选修							</td>							<td align="center">													 	    </td>						</tr>											<tr class="odd" onMouseOut="this.className='even';" onMouseOver="this.className='evenfocus';">							<td align="center">								00000998							</td>							<td align="center">								02								</td>							<td align="center">								大型数据库系统							</td>							<td align="center">								Oracle database system							</td>							<td align="center">								2.5							</td>							<td align="center">								学科选修							</td>							<td align="center">																88													 	    </td>						</tr>											<tr class="odd" onMouseOut="this.className='even';" onMouseOver="this.className='evenfocus';">							<td align="center">								SJ000195							</td>							<td align="center">								07								</td>							<td align="center">								综合实训(二)							</td>							<td align="center">								Comprehensive Practical Training(Ⅱ)							</td>							<td align="center">								2							</td>							<td align="center">								实践环节							</td>							<td align="center">													 	    </td>						</tr>											<tr class="odd" onMouseOut="this.className='even';" onMouseOver="this.className='evenfocus';">							<td align="center">								00005054							</td>							<td align="center">								02								</td>							<td align="center">								信息安全技术B							</td>							<td align="center">								Information Security Technology B							</td>							<td align="center">								2.5							</td>							<td align="center">															</td>							<td align="center">													 	    </td>						</tr>											<tr class="odd" onMouseOut="this.className='even';" onMouseOver="this.className='evenfocus';">							<td align="center">								00004773							</td>							<td align="center">								01								</td>							<td align="center">								软件项目管理B							</td>							<td align="center">								Project Managenent for Software B							</td>							<td align="center">								2.5							</td>							<td align="center">															</td>							<td align="center">													 	    </td>						</tr>												</TABLE>			<div align="right">			<table width="100%" border="0" cellpadding="0" cellspacing="0" ><tr><td align="right">共9项  第1/1页  <img  src="/static/imghw/default1.png"  data-src="/img/icon/noDownDM2.gif"  class="lazy"  title="第一页"   style="max-width:90%"  style="max-width:90%"  style="max-width:90%" / alt="使用crul抓取内容的时候。" > <img  src="/static/imghw/default1.png"  data-src="/img/icon/noDownDM_2.gif"  class="lazy"  title="前一页"   style="max-width:90%"  style="max-width:90%"  style="max-width:90%" / alt="使用crul抓取内容的时候。" ><img  src="/static/imghw/default1.png"  data-src="/img/icon/noUpDM_2.gif"  class="lazy"  title="下一页"   style="max-width:90%"  style="max-width:90%"  style="max-width:90%" / alt="使用crul抓取内容的时候。" > <img  src="/static/imghw/default1.png"  data-src="/img/icon/noUpDM2.gif"  class="lazy"  title="最后一页"   style="max-width:90%"  style="max-width:90%"  style="max-width:90%" / alt="使用crul抓取内容的时候。" >  每页显示的记录数 <select name="pageSize" onchange="pageSizeChange()"><option value="10" >10项</option><option value="20" selected='selected'>20项</option><option value="30" >30项</option><option value="40" >40项</option><option value="50" >50项</option><option value="100" >100项</option><option value="200" >200项</option><option value="300" >300项</option></select><input   name="page"   type="hidden"   id="page" value="1"> <input   name="currentPage"   type="hidden"   id="currentPage" value="1"> <input   name="pageNo"   type="text"   id="pageNo"   size="3"   onKeyPress="return   handleEnterOnPageNo();"> <img  src="/static/imghw/default1.png"  data-src="/img/icon/go.gif"  class="lazy"    name="goto"  id="goto"   style="max-width:90%" title="跳转到" onClick="forward();" alt="使用crul抓取内容的时候。" ><script   type   =   'text/javaScript'>function   forward(){     if(!(/^([1-9])(\d{0,})(\d{0,})$/.test(document.all.pageNo.value))){         alert("请输入合法的页号!");         document.all.pageNo.focus();         return false;     }     if(document.all.pageNo.value>1     ){     alert("输入的页数超过了总页数,请重新输入!");         document.all.pageNo.focus();         return false;     }         window.location.href="/bxqcjcxAction.do?totalrows=9&page="+   document.all.pageNo.value +"&pageSize="+document.all.pageSize.value;}function   handleEnterOnPageNo(){     if(event.keyCode   ==   13)     {         forward();         return   false;     }     return   true;}function pageSizeChange(){ window.location.href="/bxqcjcxAction.do?totalrows=9&pageSize="+document.all.pageSize.value;}function pagination(value){ window.location.href="/bxqcjcxAction.do?totalrows=9&page="+value+"&pageSize="+document.all.pageSize.value;}</script></td></tr></table>			</div>		</form>	</body></html>
Copy after login

我只要课程的名字和分数。。

建议把你的代码贴出来以供分析 求解答、、、

$s=你的串
preg_match_all('#

\s*.+\s*.+\s*(.+).+([^\s* #isU',$s,$m);
print_r($m);  // $m[1] 为名字数组,$m[2] 为分数数组

会不会跟网站的防抓取规则有关呢

$s=你的串
preg_match_all('#

\s*.+\s*.+\s*(.+).+([^\s* #isU',$s,$m);
print_r($m);  // $m[1] 为名字数组,$m[2] 为分数数组
太牛鼻了啊。。。我的偶像!!!!

$s=你的串
preg_match_all('#

\s*.+\s*.+\s*(.+).+([^\s* #isU',$s,$m);
print_r($m);  // $m[1] 为名字数组,$m[2] 为分数数组
大神……([^
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Describe the SOLID principles and how they apply to PHP development. Describe the SOLID principles and how they apply to PHP development. Apr 03, 2025 am 12:04 AM

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to automatically set permissions of unixsocket after system restart? How to automatically set permissions of unixsocket after system restart? Mar 31, 2025 pm 11:54 PM

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

How to debug CLI mode in PHPStorm? How to debug CLI mode in PHPStorm? Apr 01, 2025 pm 02:57 PM

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

Explain the concept of late static binding in PHP. Explain the concept of late static binding in PHP. Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

How to send a POST request containing JSON data using PHP's cURL library? How to send a POST request containing JSON data using PHP's cURL library? Apr 01, 2025 pm 03:12 PM

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

See all articles