[置顶] 拿帝吧检测bug の phpQuery 捉虫记

1 篇文章 0 订阅
1 篇文章 0 订阅

今天有个专题需求,摘取豆瓣/帝吧中针对某个关键字对其中的主题列表中的评论采集下来

 

之前使用java的jsoup搞过类似功能,使用php使用就找到了 phpQuery.

 

// 抓女神活动使用的数据
set_time_limit(0);

require_once 'ApiCommon.php';
require_once 'utils/phpQuery.class.php';
require_once 'utils/CB.class.php';
require_once 'utils/XmlExcelExport.class.php';

error_reporting( E_ALL & ~(E_STRICT | E_NOTICE | E_WARNING) );
ini_set('display_errors', 1);

//定义数据源
$source = array(
	'playgame' => array(
		'href' => 'http://www.douban.com/group/search?cat=1013&q=玩游戏',
		'kw' => '玩游戏',
		'filename' => 'playgame.xls',
		'function' => 'd_playgame',
	),
	'qijilanqiu' => array(
		'href' => 'http://tieba.baidu.com/f?ie=utf-8&kw=奇迹篮球',
		'kw' => '奇迹篮球',
		'filename' => 'qijilanqiu.xls',
		'function' => 'd_di8',
	),
	'nvshenlianmeng' => array(
		'href' => 'http://tieba.baidu.com/f?ie=utf-8&kw=女神联盟',
		'kw' => '女神联盟',
		'filename' => 'nvshenlianmeng.xls',
		'function' => 'd_di8',
	),
	'maoxianqiyue' => array(
		'href' => 'http://tieba.baidu.com/f?ie=utf-8&kw=冒险契约',
		'kw' => '冒险契约',
		'filename' => 'maoxianqiyue.xls',
		'function' => 'd_di8',
	),
	
);

// --- 实际写

if ( empty($_GET['out']) )
{
	FuelCli::write("param `out` not set");
	exit;
}
$out = trim($_GET['out']);

if ( empty($source[ $out ]) )
{
	FuelCli::write("param `out` not valid: `{$out}`");
	exit;
}

$outfile = APPOUTBOX . '/' . $source[ $out ]['filename'];

$GLOBALS['_fpout'] = CoreFileOutput::instance($outfile);

FuelCli::write("create `_outbox/{$out}`");

$GLOBALS['_fpout']->text(XmlExcelExport::instance()->generateXMLHeader());

$GLOBALS['_fpout']->text( XmlExcelExport::instance()->worksheetStart( $source[ $out ]['kw'] ) );

//
//$GLOBALS['_fpout']->text(XmlExcelExport::instance()->setTableHeader( array(
//	'内容',
//)));


# 执行数据抓取方法
Core_Helper_Callback::getInstance()
	->set( $out , $source[ $out ]['function'])
	->call($out, array( $source[ $out ]['href'] ) );


$GLOBALS['_fpout']->text(XmlExcelExport::instance()->worksheetEnd());

$GLOBALS['_fpout']->text(XmlExcelExport::instance()->generateXMLFoot());

$GLOBALS['_fpout']->close();

$msg = sprintf("create success! time: %d, mem: %.4fM , File: `_outbox/%s`.", time() - APP_START_TIMESTAMP, (memory_get_usage()  / (1024*1024)) ,$out );

FuelCli::write($msg);

 

 

采集 豆瓣 没啥问题,很简单的取打开页面,例如:

// ## [玩游戏] 数据采集

function d_playgame( $url )
{
		
	# 通过分析页面规则得到,每页显示50条,可以通过参数 start=0 来控制
	
	phpQuery::newDocumentFileHTML($url,'utf-8');	
	
	// 在第一页中先求出共有多少页主题
	$firstPage = pq('div.paginator > span.thispage')->text();
	$endPage = pq('div.paginator > a:last')->text();
	
	if ( $endPage > 100 ) $endPage = 50;
	FuelCli::write( p_text("总页数: {$endPage}") );
	
	FuelCli::write( p_text( "处理第 `1` 页: " . $url ) );
	
	# 主题数组
	$topics = d_playgame_topics( pq('div.topics > table.olt') );
	phpQuery::$documents = array();# 释放内存,减少内存调用
	
	# 解析主题获取评论
	d_playgame_topics_parse( $topics );
		
	for ( $page=2;$page<=$endPage;$page++ )
	{
		# 暂停1秒,看是否能通过浏览器
		sleep(1);
		
		$start = ($page - 1) * 50;
		
		$purl = $url . '&start=' . $start;
		
		FuelCli::write( p_text( "处理第 `{$page}` 页: " . $purl ) );
		
		# 加载 页面
		phpQuery::newDocumentFileHTML( $purl ,'utf-8');		
		# 找到主题数组
		$topics = d_playgame_topics( pq('div.topics > table.olt') );
		phpQuery::$documents = array();# 释放内存,减少内存调用
		
		# 解析主题获取评论
		d_playgame_topics_parse( $topics );		
	}
	
}

/**
 * 解析 页面主题,返回对应的数组
 * 
 * @param phpQuery $doc
 * 
 * @return array
 */
function d_playgame_topics( $doc )
{
	$topics = array();
	
	foreach ( pq('tr.pl > td.td-subject > a',$doc) as $item )
	{
		$topics[ pq($item)->attr('href') ] = pq($item)->attr('title');
	}
	
	return $topics;
}

/**
 * 解析主题获取评论
 * 
 * @param array $topics
 * 
 * @return void
 */
function d_playgame_topics_parse( $topics )
{
	FuelCli::write( p_text( "主题数: " . count($topics) ) );
	
	$index = 0;
	foreach ( $topics as $href=>$topic )
	{
		$index ++;
		FuelCli::write( p_text( " -- {$index}: " . $href ) );
		
		# 对每个主题进行取评论
		d_playgame_topic_parse( $topic , $href );
		
		# 延迟 0.1 秒再进行请求
		usleep(100000);
	}

}

/**
 * 获取评论内容列表
 * 
 * @param string $topic
 * @param string $href
 * 
 * @return void
 */
function d_playgame_topic_parse( $topic , $href )
{		
	# 加载 页面
	phpQuery::newDocumentFileHTML( $href ,'utf-8');		
	# 提取评论项集合
	
	$index = 0;
	$comments = '';# 减少i/o写操作
	foreach ( pq('ul#comments > li.comment-item > div.reply-doc > p') as $item )
	{
		$comments .=  XmlExcelExport::instance()->parseRow( array( pq( $item )->text() ) );
		
		$index++;
	}
	$GLOBALS['_fpout']->text( $comments );
	
	phpQuery::$documents = array();# 释放内存,减少内存调用
	
	FuelCli::write( p_text( " --  -- 评论数: " . $index ) );
}

 

但是 采集帝吧的时候就出现问题了,帝吧使用的是GBK编码的,这就悲催了,

$url="http://tieba.baidu.com/f?ie=utf-8&kw=奇迹篮球";
phpQuery::newDocumentFileHTML($url,'gbk');
$t = pq('title')->html();

echo mb_detect_encoding ($t);// result is : UTF-8
echo $t; // this is  乱码

 这就出现乱码了,仔细阅读其代码发现,貌似这大哥的第二个参数基本就是没有用的,很无奈的选择啊..

 

自己动手丰衣足食,色色只好自己上手了...

function d_di8_open( $url )
{
	$cnt = file_get_contents($url);
	return mb_convert_encoding($cnt ,"UTF-8","GBK");
}
$url="http://tieba.baidu.com/f?ie=utf-8&kw=奇迹篮球";
phpQuery::newDocumentHTML( d_di8_open($url) );	
$t = pq('title')->html();

echo mb_detect_encoding ($t);// result is : UTF-8
echo $t; // this is right

 这样就正确了,所以 亲们使用 phpQuery 如果目标页面是 gbk或者其它非utf-8编码的,先进行内容抓取做转码吧,例如:

/**
 * 获取评论内容列表
 * 
 * @param string $topic
 * @param string $href
 * 
 * @return void
 */
function d_di8_topic_parse( $topic , $href )
{		
	# 加载 页面
	phpQuery::newDocumentHTML( d_di8_open($href) );		
	# 提取评论项集合
	$index = 0;
	$comments = '';# 减少i/o写操作
	foreach ( pq('div.p_content > cc > div.d_post_content') as $item )
	{
		// 因为帝吧使用的是GBK编码,故此处将其转成 utf-8编码
//		$text = p_text( pq( $item )->text() );
		$text = pq( $item )->text();
//		FuelCli::write( $text );	
		$comments .=  XmlExcelExport::instance()->parseRow( array( $text ) );
		
		$index++;
	}
	$GLOBALS['_fpout']->text( $comments );
	
	phpQuery::$documents = array();# 释放内存,减少内存调用
	
	FuelCli::write( p_text( " --  -- 评论数: " . $index ) );
}

 

输入如下:

写道
D:\phpeclipse\workspace\wyxcli>php crawl20130821.php out=qijilanqiu
create `_outbox/qijilanqiu`
总页数: 1
处理第 `1` 页: http://tieba.baidu.com/f?ie=utf-8&kw=奇迹篮球
主题数: 50
-- 1: http://tieba.baidu.com/p/2534641226
-- -- 评论数: 6
-- 2: http://tieba.baidu.com/p/2527963747
-- -- 评论数: 2
-- 3: http://tieba.baidu.com/p/2529999511
-- -- 评论数: 7
-- 4: http://tieba.baidu.com/p/2553290615
-- -- 评论数: 5
-- 5: http://tieba.baidu.com/p/2527658421
-- -- 评论数: 4
-- 6: http://tieba.baidu.com/p/2442517157
-- -- 评论数: 3
-- 7: http://tieba.baidu.com/p/2552547772
-- -- 评论数: 5
-- 8: http://tieba.baidu.com/p/2551704915
-- -- 评论数: 3
-- 9: http://tieba.baidu.com/p/2546812394
-- -- 评论数: 4
-- 10: http://tieba.baidu.com/p/2551321130
-- -- 评论数: 2
-- 11: http://tieba.baidu.com/p/2548341950
-- -- 评论数: 4
-- 12: http://tieba.baidu.com/p/2519520372
-- -- 评论数: 11
-- 13: http://tieba.baidu.com/p/2545480033
-- -- 评论数: 4
-- 14: http://tieba.baidu.com/p/2546529051
-- -- 评论数: 3
-- 15: http://tieba.baidu.com/p/2535490334
-- -- 评论数: 14
-- 16: http://tieba.baidu.com/p/2517910085
-- -- 评论数: 13
-- 17: http://tieba.baidu.com/p/2529226727
-- -- 评论数: 2
-- 18: http://tieba.baidu.com/p/2544406437
-- -- 评论数: 7
-- 19: http://tieba.baidu.com/p/2539768377
-- -- 评论数: 4
-- 20: http://tieba.baidu.com/p/2534831859
-- -- 评论数: 2
-- 21: http://tieba.baidu.com/p/2537294810
-- -- 评论数: 3
-- 22: http://tieba.baidu.com/p/2542824941
-- -- 评论数: 2
-- 23: http://tieba.baidu.com/p/2541489544
-- -- 评论数: 7
-- 24: http://tieba.baidu.com/p/2540771551
-- -- 评论数: 8
-- 25: http://tieba.baidu.com/p/2539424700
-- -- 评论数: 4
-- 26: http://tieba.baidu.com/p/2540409043
-- -- 评论数: 4
-- 27: http://tieba.baidu.com/p/2539426813
-- -- 评论数: 5
-- 28: http://tieba.baidu.com/p/2539158959
-- -- 评论数: 4
-- 29: http://tieba.baidu.com/p/2538418239
-- -- 评论数: 5
-- 30: http://tieba.baidu.com/p/2539133118
-- -- 评论数: 2
-- 31: http://tieba.baidu.com/p/2536895475
-- -- 评论数: 2
-- 32: http://tieba.baidu.com/p/2539120530
-- -- 评论数: 4
-- 33: http://tieba.baidu.com/p/2538414986
-- -- 评论数: 2
-- 34: http://tieba.baidu.com/p/2536462810
-- -- 评论数: 6
-- 35: http://tieba.baidu.com/p/2534324575
-- -- 评论数: 4
-- 36: http://tieba.baidu.com/p/2524771361
-- -- 评论数: 8
-- 37: http://tieba.baidu.com/p/2532300903
-- -- 评论数: 20
-- 38: http://tieba.baidu.com/p/2528784304
-- -- 评论数: 8
-- 39: http://tieba.baidu.com/p/2528627411
-- -- 评论数: 4
-- 40: http://tieba.baidu.com/p/2532123359
-- -- 评论数: 7
-- 41: http://tieba.baidu.com/p/2529977911
-- -- 评论数: 5
-- 42: http://tieba.baidu.com/p/2533014180
-- -- 评论数: 5
-- 43: http://tieba.baidu.com/p/2529027118
-- -- 评论数: 5
-- 44: http://tieba.baidu.com/p/2527961913
-- -- 评论数: 2
-- 45: http://tieba.baidu.com/p/2519577941
-- -- 评论数: 9
-- 46: http://tieba.baidu.com/p/2532019472
-- -- 评论数: 1
-- 47: http://tieba.baidu.com/p/2531388657
-- -- 评论数: 15
-- 48: http://tieba.baidu.com/p/2531892898
-- -- 评论数: 1
-- 49: http://tieba.baidu.com/p/2520463405
-- -- 评论数: 3
-- 50: http://tieba.baidu.com/p/2525360009
-- -- 评论数: 3
create success! time: 19, mem: 1.4663M , File: `_outbox/qijilanqiu`.

D:\phpeclipse\workspace\wyxcli>php crawl20130821.php out=qijilanqiu
create `_outbox/qijilanqiu`
总页数: 尾页
处理第 `1` 页: http://tieba.baidu.com/f?ie=utf-8&kw=奇迹篮球
主题数: 50
-- 1: http://tieba.baidu.com/p/2534641226
-- -- 评论数: 6
-- 2: http://tieba.baidu.com/p/2527963747
-- -- 评论数: 2
-- 3: http://tieba.baidu.com/p/2529999511
-- -- 评论数: 7
-- 4: http://tieba.baidu.com/p/2553290615
-- -- 评论数: 5
-- 5: http://tieba.baidu.com/p/2527658421
-- -- 评论数: 4
-- 6: http://tieba.baidu.com/p/2442517157
-- -- 评论数: 3
-- 7: http://tieba.baidu.com/p/2552547772
-- -- 评论数: 5
-- 8: http://tieba.baidu.com/p/2551704915
-- -- 评论数: 3
-- 9: http://tieba.baidu.com/p/2546812394
-- -- 评论数: 4
-- 10: http://tieba.baidu.com/p/2551321130
-- -- 评论数: 2
-- 11: http://tieba.baidu.com/p/2548341950
-- -- 评论数: 4
-- 12: http://tieba.baidu.com/p/2519520372
-- -- 评论数: 11
-- 13: http://tieba.baidu.com/p/2545480033
-- -- 评论数: 4
-- 14: http://tieba.baidu.com/p/2546529051
-- -- 评论数: 3
-- 15: http://tieba.baidu.com/p/2535490334
-- -- 评论数: 14
-- 16: http://tieba.baidu.com/p/2517910085
-- -- 评论数: 13
-- 17: http://tieba.baidu.com/p/2529226727
-- -- 评论数: 2
-- 18: http://tieba.baidu.com/p/2544406437
-- -- 评论数: 7
-- 19: http://tieba.baidu.com/p/2539768377
-- -- 评论数: 4
-- 20: http://tieba.baidu.com/p/2534831859
-- -- 评论数: 2
-- 21: http://tieba.baidu.com/p/2537294810
-- -- 评论数: 3
-- 22: http://tieba.baidu.com/p/2542824941
-- -- 评论数: 2
-- 23: http://tieba.baidu.com/p/2541489544
-- -- 评论数: 7
-- 24: http://tieba.baidu.com/p/2540771551
-- -- 评论数: 8
-- 25: http://tieba.baidu.com/p/2539424700
-- -- 评论数: 4
-- 26: http://tieba.baidu.com/p/2540409043
-- -- 评论数: 4
-- 27: http://tieba.baidu.com/p/2539426813
-- -- 评论数: 5
-- 28: http://tieba.baidu.com/p/2539158959
-- -- 评论数: 4
-- 29: http://tieba.baidu.com/p/2538418239
-- -- 评论数: 5
-- 30: http://tieba.baidu.com/p/2539133118
-- -- 评论数: 2
-- 31: http://tieba.baidu.com/p/2536895475
-- -- 评论数: 2
-- 32: http://tieba.baidu.com/p/2539120530
-- -- 评论数: 4
-- 33: http://tieba.baidu.com/p/2538414986
-- -- 评论数: 2
-- 34: http://tieba.baidu.com/p/2536462810
-- -- 评论数: 6
-- 35: http://tieba.baidu.com/p/2534324575
-- -- 评论数: 4
-- 36: http://tieba.baidu.com/p/2524771361
-- -- 评论数: 8
-- 37: http://tieba.baidu.com/p/2532300903
-- -- 评论数: 20
-- 38: http://tieba.baidu.com/p/2528784304
-- -- 评论数: 8
-- 39: http://tieba.baidu.com/p/2528627411
-- -- 评论数: 4
-- 40: http://tieba.baidu.com/p/2532123359
-- -- 评论数: 7
-- 41: http://tieba.baidu.com/p/2529977911
-- -- 评论数: 5
-- 42: http://tieba.baidu.com/p/2533014180
-- -- 评论数: 5
-- 43: http://tieba.baidu.com/p/2529027118
-- -- 评论数: 5
-- 44: http://tieba.baidu.com/p/2527961913
-- -- 评论数: 2
-- 45: http://tieba.baidu.com/p/2519577941
-- -- 评论数: 9
-- 46: http://tieba.baidu.com/p/2532019472
-- -- 评论数: 1
-- 47: http://tieba.baidu.com/p/2531388657
-- -- 评论数: 15
-- 48: http://tieba.baidu.com/p/2531892898
-- -- 评论数: 1
-- 49: http://tieba.baidu.com/p/2520463405
-- -- 评论数: 3
-- 50: http://tieba.baidu.com/p/2525360009
-- -- 评论数: 3
create success! time: 19, mem: 1.4663M , File: `_outbox/qijilanqiu`.

 

 本着将坏事做绝的心态给官方提了个issue,

 http://code.google.com/p/phpquery/issues/detail?id=232&thanks=232&ts=1377515316

 

 

phpQuery乱码的终极解决方案 写道

phpQuery乱码的终极解决方案

phpQuery是一款JQuery的PHP实现,用来解析网页元素DOM非常的方便,头疼的是他总是有乱码问题。其实也不能全怪phpQuery。
因为phpQuery分析网页元素时候进行网页编码探测使用的是正则表达式进行页面meta标签的charset匹配。但是总是有那么多奇形怪状的网页,所以也难免会出错。
比如这个页面 他就没有meta标签,phpQuery在处理这个页面的时候(function loadMarkupHTML),就会遵循如下流程

if(正则表达式匹配meta标签失败,即documentCharset变量空){
if(定义了requestedCharset,就是那个newDocumentFileHTML后面的charset参数){
charset = requestedCharset
}
if(charset还不能被定义,即requestedCharset为空){
charset = phpQuery::$defaultCharset
}
if(documentCharset变量空){
根据HTTP 1.1的要求 设置默认documentCharset为ISO-8859-1
需要在后面补足标准的meta标记
}
}
if (requestedCharset && documentCharset && requestedCharset !== documentCharset){
如果存在mb_detect_encoding的话,进行编码转换
possibleCharsets = array(documentCharset, requestedCharset, 'AUTO')
docEncoding = mb_detect_encoding(markup, implode(', ', possibleCharsets));
if(检测不出docEncoding){
已documentCharset为准
}
if(docEncoding这个检测编码和requestedCharset不一样){
使用mb_convert_encoding进行编码转换
}

}
其余略

这里面有个问题,那就是mb_detect_encoding检测的编码不一定是准确的,大部分情况下,在ISO-8859-1优先的情况下(documentCharset排在前面),他都认为该文档是ISO-8859-1,从而出现乱码。
所以,如果你这里定义了phpQuery::$defaultCharset,就可以避免这种情况的发生,这样的话 采集淘宝网首页 只要指定phpQuery::$defaultCharset=GBK,就不会乱码。
第二个问题是一个BUG,在phpQuery的大概273行(phpQuery 0.9.5 (r386; one file release) )

$markup = $this->charsetFixHTML($markup);
1

$markup = $this->charsetFixHTML($markup);

这个BUG会导致中文wordpress博客,比如我这个博客,虽然有规范的meta标签 但是会被错误的charsetFixHTML。破坏了DOM结构,导致解析乱码。该BUG到Revision 393依旧没修复。 这个不注释的话,采集我的博客就会乱码.

所以 这里有我的一个修补版本,有兴趣的可以下了试试。phpQuery-onefile-ipatched|Dropbox|
由于PHPQuery是精确采集,所以你之前基本知道了网页的编码,那么只要指定了phpQuery::$defaultCharset,不管是有没有meta的页面或者meta不规范的页面,基本上都不会乱码。

规范的HTML页面演示

<?php //规范meta演示 header("Content-type: text/html; charset=utf-8"); set_time_limit(0); include 'phpQuery-onefile-ipatched.php'; //phpQuery::$defaultCharset = 'euc-jp'; phpQuery::newDocumentFileHTML('http://page14.auctions.yahoo.co.jp/jp/auction/s237346475'); echo pq('title')->text(); echo pq("strong[property='auction:Price'])")->text(); ?>
1
2
3
4
5
6
7
8
9
10

<?php
//规范meta演示
header("Content-type: text/html; charset=utf-8");
set_time_limit(0);
include 'phpQuery-onefile-ipatched.php';
//phpQuery::$defaultCharset = 'euc-jp';
phpQuery::newDocumentFileHTML('http://page14.auctions.yahoo.co.jp/jp/auction/s237346475');
echo pq('title')->text();
echo pq("strong[property='auction:Price'])")->text();
?>

不规范的页面演示

<?php //不规范meta演示 header("Content-type: text/html; charset=utf-8"); set_time_limit(0); include 'phpQuery-onefile-ipatched.php'; phpQuery::$defaultCharset = 'euc-jp'; phpQuery::newDocumentFileHTML('http://storeuser11.auctions.yahoo.co.jp/jp/user/makototakahashi0316?alocale=0jp&mode=0&u=makototakahashi0316'); $trs = pq('#list01')->find('table tr:not(:first)'); foreach($trs as $tr){ $line = pq($tr)->find('td:first a'); $title = $line->text(); if($title){ $url = $line->attr('href'); echo $title.'---->'.$url.'<br />'; } } ?>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

<?php
//不规范meta演示
header("Content-type: text/html; charset=utf-8");
set_time_limit(0);
include 'phpQuery-onefile-ipatched.php';
phpQuery::$defaultCharset = 'euc-jp';
phpQuery::newDocumentFileHTML('http://storeuser11.auctions.yahoo.co.jp/jp/user/makototakahashi0316?alocale=0jp&mode=0&u=makototakahashi0316');
$trs = pq('#list01')->find('table tr:not(:first)');
foreach($trs as $tr){
$line = pq($tr)->find('td:first a');
$title = $line->text();
if($title){
$url = $line->attr('href');
echo $title.'---->'.$url.'<br />';
}
}
?>

<?php //规范meta演示 header("Content-type: text/html; charset=utf-8"); set_time_limit(0); include 'phpQuery-onefile-ipatched.php'; //phpQuery::$defaultCharset = 'euc-jp'; phpQuery::newDocumentFileHTML('http://ihipop.info'); echo pq("title")->text(); //不规范meta演示 phpQuery::$defaultCharset = 'GBK'; phpQuery::newDocumentFileHTML('http://taobao.com'); echo pq("title")->text(); ?>
1
2
3
4
5
6
7
8
9
10
11
12
13

<?php
//规范meta演示
header("Content-type: text/html; charset=utf-8");
set_time_limit(0);
include 'phpQuery-onefile-ipatched.php';
//phpQuery::$defaultCharset = 'euc-jp';
phpQuery::newDocumentFileHTML('http://ihipop.info');
echo pq("title")->text();
//不规范meta演示
phpQuery::$defaultCharset = 'GBK';
phpQuery::newDocumentFileHTML('http://taobao.com');
echo pq("title")->text();
?>

注意 1.phpQuery的输出全部是UTF-8编码的.
2.phpQuery主页http://code.google.com/p/phpquery/

phpQuery在每处理一个网页就会产生一个DOMDocumentWrapper 对象,而每个DOMDocumentWrapper 对象会被保存在静态成员$documents中(phpQuery::createDocumentWrapper中),这个变量是一个数组,每解析一个网页数组元素就增加一个。如果不想让自己的内存被额沾满,每次解析完一个网页,把phpQuery::$documents置空
phpQuery::$documents = array();
1

phpQuery::$documents = array();

或者清空不必要的ID,节省内存。同理,你也可以有选择的保留一些ID 见http://code.google.com/p/phpquery/wiki/MultiDocumentSupport

Author Info :
From:phpQuery乱码的终极解决方案
URL:http://blog.ihipop.info/2011/08/2647.html
Please Reserve This Link,Thanks!

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值