Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

获取数据的时候,数据重复插入 #79

Closed
crashsol opened this issue Oct 20, 2018 · 2 comments
Closed

获取数据的时候,数据重复插入 #79

crashsol opened this issue Oct 20, 2018 · 2 comments

Comments

@crashsol
Copy link

通过 AddEntityType();
获取busstoplist 下所有P元素的内容
http://wapapp.dy4g.cn/bus/auto/test.php?t=linhtml&busline=1
123
`

        /// <summary>
        /// 获取车站信息
        /// </summary>
        [Schema("dybus", "BusStation")]
        [Entity(Expression = ".//div[@class='busstoplist']/div//p", Type = SelectorType.XPath)]
        class BusStation : BaseEntity
        {
            /// <summary>
            /// 车次信息
            /// </summary>
            [Column]
            [Field(Expression = "Keyword", Type = SelectorType.Enviroment)]
            public string Keyword { get; set; }

            /// <summary>
            /// 车站唯一ID
            /// </summary>
            [Column]
            [Field(Expression = "./@Id")]
            public string BusStationId { get; set; }


            /// <summary>
            /// 车次路线编号
            /// </summary>
            [Column]
            [Field(Expression = "./strong/text()")]
            public string StationNumber { get; set; }

            /// <summary>
            /// 车站名称
            /// </summary>
            [Column]
            [Field(Expression = "./span/text()")]
            public string Name { get; set; }

            /// <summary>
            /// 车站方向
            /// </summary>
            [Column]
            [Field(Expression = "../@class")]
            public string BusDirection { get; set; }

        }

`

2222

数据是能够获取到,
但是获取到的同一条数据插入了两次

请老师看看,是不是我使用姿势不对

@crashsol crashsol reopened this Oct 20, 2018
@crashsol
Copy link
Author

crashsol commented Oct 20, 2018

好像还是不行,是不是XPATH有问题啊
1
2
3

这三种方式都试过了,还是不行,在浏览器里面都只匹配出来67次,
但是数据库中,数据都插入了两次
1

@crashsol
Copy link
Author

    AddEntityType<BusLineCarBatchNo>();
    AddEntityType<BusStation>();       
  AddPipeline(new ConsoleEntityPipeline());
   AddPipeline(new MySqlEntityPipeline(DbConnection));     

根据页面dom结构,调整AddEntityType分析的顺序,能够正确获取数据!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant