rq204 发表于 2008-11-6 17:11:24

对于分页中使用脚本控制分页的采集方法

我们以 http://post.she.tom.com/C600093857.html 为例,这里是用脚本来控制分页的,具体的有关分页的代码//current page of append
var cur_append_page = 1;
var total_append_page = 3 ;这里的3是总页数.我们看一下分页的特点.第二页http://post.she.tom.com/C600093857_2.html ,第三页http://post.she.tom.com/C600093857_3.html ,第一页另一个表示是http://post.she.tom.com/C600093857_1.html

目前程序处理这个还是不便,所以我们写些小程序,将分页代码弄成明文形式,再交给程序去处理.

目前,对于这个页面,我们用php写个小程序.代码如下:
<?php
include "Snoopy-1.2.4/Snoopy.class.php";
$tom=new Snoopy;
$URI='http://post.she.tom.com/C600093857.html';
$c=$tom->fetch($URI);
$content=$tom->results;
preg_match("/var total_append_page = (\d+) ;/",$content,$pagenum);
$num=$pagenum['1'];
echo '<div id=locoypages>';
for($i=1;$i<$num+1;$i++){
echo '<a href="'.str_replace('.html','_'.$i.'.html',$URI).'">'.$i.'</a>';
}
echo '</div>';
?>然后用火车采集,就可以得到所有内容.


基本原理就这样,你可以自己想出更好的办法.

aven 发表于 2008-11-6 17:17:02

good!!!!!!!!!!!!!!!!!!!!!

:ali12ls :ali12ls

xiongyujie37 发表于 2008-11-6 18:10:07

可是 我看不懂。。。

chenfy 发表于 2008-11-7 12:07:50

正在学习php编程,还能看懂一点点,呵呵,努力中,争取也来写接口!

songtao 发表于 2008-11-26 15:30:44

没有发布类文件...没用.

5949772 发表于 2008-12-12 09:22:56

谢谢!
希望楼主能够说明一下,遇到类似的情况那些可以修改.PHP不大懂,实在不好意思!
:ali1ls

zhwxc 发表于 2008-12-13 22:04:10

唉努力学习争取早日成为老鸟

ahligaoming 发表于 2009-2-6 09:52:52

不是很懂,顶吧!

8qzone 发表于 2009-2-7 00:37:03

你写完这个代码放到哪里啊,怎么也不说明一下怎么用啊?

fetionclub 发表于 2009-2-10 12:17:34

是啊,没有说明白啊。
页: [1] 2
查看完整版本: 对于分页中使用脚本控制分页的采集方法