smartscript添加feed方法(二)

[复制链接]
查看: 1721   回复: 9
发表于 2004-7-27 06:51:44 | 显示全部楼层 |阅读模式
声明:这些都是自己摸索的,有些地方不是很完善哦,没有看全代码
也不是太明白

拿scritpt professor 2.94b说,我们测试添加一个gofeed的feed:

需要修改2个文件,如果不需要在界面中修改,改一个文件也就够了
CRAWL.CGI、admin-settings.txt
其实修改的方法比较简单,就是照抄类似的脚本,比如在admin-setting中:

脚本里面有www.revenuepilot.com吧,
<a href="http://www.revenuepilot.com/smarterscripts/index.jsp">RevenuePILOT</a> (affiliate program)&5~后面你添加:<a href="http://gofeed.com">gofeed</a> (affiliate program)&18~
我们把他定义成18号feed站。记住这个18

RevenuePILOT|heading|
If you selected RevenuePilot above, enter your affiliate ID here. RevenuePILOT is another good affiliate program that pays you for referring clicks. Sign up by clicking <a href="http://www.revenuepilot.com/smarterscripts/index.jsp">here</a>|rp_id|1&10
RevenuePILOT's family filter (to filter out adult sites from the listings RevenuePilot returns):|rp_filter|2&On&1~Off&0
How Many RevenuePILOT Results Would You Like To Show?|results_rpilot|1&5
What percentage of the advertisers bid do you earn from RevenuePILOT?<br>(35 = 35%, etc.)|commission_rpilot|1&5

这个你就复制粘贴一下,把里面文字改成gofeed的说明.改rp_id为gofeed_id,commision_rpilot改成commision_gofeed依次类推。
对了,要把family filter 这一行去掉,对gofeed没什么用,留着也没关系
CRAWL.CGI中也要做这样的修改和添加。


$rpilot = 5;后面加上一行
$gofeed = 18;OK,做了以上修改,能用了吗?如果你运气好,2个站的feed格式相同,你就不用改,直接可以用了。
不过看样子不行哦。我们测试一下:

浏览器中打开网址:
http://gofeed.com/cgi-bin/smarts ... mp;ip=64.134.51.231
嗯,显示正常了,

<Listings>  <Listing>
    <bid>0.019</bid>
    <title>casino, up to $200 free, GoldenPalace.com</title>
    <url>http://www.gofeed.com/cgi-bin/sm ... fhxzv&kw=casino</url>
    <description>Best offer on the Net - Deposit $25 to $100 and get 200% more money up to $200! Established in 1997, Golden Palace is a pioneer of the online gaming industry and the most trusted name in the business.</description>
    <domain>www.goldenpalace.com</domain>
  </Listing>

哎呀,这个和revenuepilot反回来数据格式不一样...
在后台处理肯定会出错,不信你传上去看看,有项目但是内容一片空白
你现在应该修改2个核心函数:
sub get_gofeed函数和sub parse_gofeed(你不会脚本中没有吧?:D刚刚“依次类推添加的呀)

sub get_gofeed
{
        $showext = $settings{results_gofeed} || 50;
        $urls{"http://www.gofeed.com/cgi-bin/smartsearch/include.cgi?keywords=$klink&external=1&show=$showext&xml=1&IP=$usersip&username=$settings{gofeed_id}&subaffiliate=$subaffiliate"} = $gofeed;
        push @engine, $xray;
        push @writetocache, 1;
}
这个就没啥可说的了,最重要就是下面一个函数:
这里要复习一下刚学的perl操作符了,()、s/PATTERN/REPLACE/eg

sub parse_gofeed
{
#注意这里是测试几行代码,记录返回的数据是否正确的,以后删除
                open(DATA, ">> log/gofeed.log");
                flock (DATA, $LOCK_EX);
                print DATA "$html\n\n\n";
                flock (DATA, $LOCK_UN);
                close(DATA);
#下面就是处理那些<Listings>  <Listing>....之类的东西了

        while ($html =~ m|    <bid>(.*?)</bid>\s+    <title>(.*?)</title>\s+<url>(.*?)</url>\s+    <description>(.*?)</description>\s+    <domain>(.*?)</domain>|igs)
#...
        {
                $realurl = $3;
                $title = $2;
#这里如果你要添加[gofeed]标志让你确认这个feed的确能用了,就可以把上面一句改成  $title = '[gofeed]'  . $2;
                $url = $5;
                $descrip = $4;
                $bid = $1;

        if($settings{commission_gofeed} ne '')
                { $bid = sprintf("%.3f",($settings{commission_sh}/100)*$bid); }

                &striphtml;
                if ($bid > 0)
                {
                        $crawlfound++;
                        push @gofeed_results, join('&&', $bid, '', $title, $url, $descrip, $realurl, '1');
#这样应该就可以了,如果运行不通过,你就试试把gofeed_result改成searchfeed_result(如果你用sf的feed的话,或者改成你其他正在使用的feed的result参数)
                }
        }
}
记得备份下原来的文件,然后上传、刷新后台admin.cgi,关闭掉其他的feed,打开gofeed选项,加个欧美超级代理搜索一下,呵呵,能看到结果了吗?ftp里面打开log目录,里面有个gofeed.log了吧,看看,正常的话就把那几句调试语句删除。OK了,^_^!

晕,不知道大家看的明白不?

[ Last edited by 苦苦 on 2004-7-27 at 11:21 ]
 楼主| 发表于 2004-7-27 06:52:24 | 显示全部楼层
写的累死了,看的懂看不懂的都加点分啊
回复 支持 反对

使用道具 举报

giggsfe 该用户已被删除
发表于 2004-7-27 07:52:40 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

发表于 2004-7-27 12:22:59 | 显示全部楼层
我看懂了前面啊,呵呵,,坚持看他一百遍,估计能懂一半了吧!
回复 支持 反对

使用道具 举报

netcat 该用户已被删除
发表于 2004-7-30 01:16:07 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

kunpengx 该用户已被删除
发表于 2004-7-30 08:54:25 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

发表于 2004-7-30 10:27:02 | 显示全部楼层
晕呀,越看越晕!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2004-7-30 15:15:36 | 显示全部楼层
谁要加feed可以PM我:)
其实不难搞的哈~:0
回复 支持 反对

使用道具 举报

netcat 该用户已被删除
发表于 2004-7-31 00:59:29 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

发表于 2004-8-4 16:01:32 | 显示全部楼层
8懂!!!但支持好帖!!!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则