phpQuery
爬取页面:http://www.idyjy.com/sub/25307.html(charset=gb2312)
涌现的问题:

当用request获取到页面
$dataDetail = $this->is_request('http://www.idyjy.com/sub/25307.html');
再用fwrite写入content.txt
$myfile = fopen(\"大众content.txt\"大众, \"大众w\"大众) or die(\"大众Unable to open file!\"大众);fwrite($myfile, $dataDetail);
再获取图片
pq(\"大众.pic img\"大众,$resDetail)->attr('original');
结果返回为空。
而content.txt里面包含完全网页代码,未创造标签和属性不存在。
办理办法:
考试测验一:
页面转码
$dataDetail = iconv(\公众gb2312\公众,\"大众utf-8//IGNORE\"大众,$dataDetail );
结果弗成。
考试测验二:粗放的将charset=gb2312改为utf-8
$dataDetail = str_replace('charset=gb2312','charset=urf-8',$dataDetail);
结果精确了,也是怪异!
当然,其他页面纵然是gb2312编码也能精确抓取,也是怪异了。