风讯官方论坛

首页 » FoosunCMS交流区 » dotNETCMS安装使用 » 终于把免费版的采集搞定了,发给大家学习!
xelnage - 2008-3-27 00:09:00
哎,终于吧免费版的采集搞定了,官方的UrlPlus这个类写的有问题!!!:default21:
Foosun.CMS 下面的 Foosun.CMS.Collect.Utility.UrlPlus 自己改了个,发给大家学习。
文件为:  \Foosun\Foosun.CMS\Collect\Utility.cs

免费版吧UrlPlus这个类换成我这个就可以了!

没有编译环境的下附件把!

        private static string UrlPlus(string front, string tail)
        {
            int num1 = 0;
            tail = tail.ToLower();
            front = front.Substring(0, front.IndexOf("/", 8));
            if (tail.StartsWith("./"))
            {
                tail = tail.Remove(0, 1);
                tail = front + tail;
            }
            else if (tail.StartsWith("/"))
            {
                tail = front + tail;
            }
            else if (tail.StartsWith("../"))
            {
                while (tail.StartsWith("../"))
                {
                    num1 = ++num1;
                    tail = tail.Remove(0, 3);
                }
                for (int num2 = 0; num2 < num1; num2++)
                {
                    front = front.Substring(0, front.LastIndexOf("/", front.Length - 2));
                }
                tail = front + "/" + tail;
            }
            if (!tail.StartsWith("http://") && !tail.StartsWith("https://"))
            {
                tail = front + "/" + tail;
            }
            return tail;
        }



 附件: 您所在的用户组无法下载或查看附件
王宇 - 2008-3-27 00:15:00
:default6: 支持下!
xelnage - 2008-3-27 12:43:00
方法2

应为Foosun.Common中的截取字符串函数有变化,所以对目标URL的处理出现一些问题,修改为RC2的处理方式问题解决.

以上2种方法任选其一.

public static string GetSubString(string Str, int Num)
        {
            if ((Str == null) || (Str == ""))
            {
                return "";
            }
            string outstr = "";
            int n = 0;
            foreach (char ch in Str)
            {
                n += System.Text.Encoding.Default.GetByteCount(ch.ToString());
                if (n > Num)
                    break;
                else
                    outstr += ch;
            }
            return outstr;
        }

编译好的文件:
 附件: 您所在的用户组无法下载或查看附件
andy145 - 2008-3-29 10:33:00
两种方法都没有成功也
xelnage - 2008-3-29 17:04:00
可能是你的采集规则没有写好,自己重新写一个,系统自己带的2个好想地址有问题采集不了.
andy145 - 2008-3-29 23:18:00

 附件: 您所在的用户组无法下载或查看附件
这里是正确的,但最后采集时就出现:

 附件: 您所在的用户组无法下载或查看附件
xelnage - 2008-3-29 23:41:00
采集规则有问题
ayurep - 2008-3-31 14:15:00
方法一二我都试了也不行,不知道为什么?  规则设置应该是对的.


还有这个采集系统的操作性上很不方便,不易调试,希望改进:default8:
xelnage - 2008-3-31 17:10:00
发一个新浪国际新闻的采集规则大家测试,顺便建议采集功能能够导入导出规则吧!


采集对象页:http://news.sina.com.cn/world/new/index.html

采集页编码方式: GB2312

列表内容: <!--开始新闻列表-->[列表内容]<!--结束新闻列表-->

列表URL: <a href=[列表URL] TARGET=_blank>

标题: <div id="artibodyTitle">
  <h1>[标题]</h1>

内容: <!--正文内容开始-->
  <!-- google_ad_section_start -->
  [内容]
  <!-- google_ad_section_end -->

作者:我设置的手动:default6:

来源:<span class="linkRed02"><a href=[变量]">[来源]</a>

时间:<div class="from_info">http://www.sina.com.cn[加入时间]<span
z10046194 - 2008-5-11 08:14:00


引用:
原帖由 xelnage 于 2008-3-31 17:10:00 发表
发一个新浪国际新闻的采集规则大家测试,顺便建议采集功能能够导入导出规则吧!


采集对象页:http://news.sina.com.cn/world/new/index.html

采集页编......





成功:0% 失败:100% 已完成100%

:default21: :default21:
xelnage - 2008-5-11 16:44:00
SP1采集以修复不用这个了,不成功的情况检查规则了
1
查看完整版本: 终于把免费版的采集搞定了,发给大家学习!