using AnfleCrawler.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace AnfleCrawler.DataAnalyzer
{
internal class Zlhome : AnalyzerBase
{
protected override void AnalyzeInternal(PageLandEntity current)
{
var lander = Crawler.Lander;
var pHandler = CreateContentHandler(current);
switch (current.Depth)
{
case :
{
var dom = lander.GetDocument(pHandler);
DoPerPaging(current, dom.DocumentNode, ".page:first-child a:last-child"); foreach (var node in QueryNodes(dom.DocumentNode, ".xqlistBox .l_img a"))
{
var url = GetHref(node, current.Url);
Crawler.PushUrl(url, DataDepth.Houses);
}
}
break;
case DataDepth.Houses:
{
var dom = lander.GetDocument(pHandler);
var attrs = new AttributeFiller(); attrs.Append("小区名称:{0}", QueryTexts(dom.DocumentNode, ".sc a").First().Replace("关注", string.Empty)); attrs.Append(QueryTexts(dom.DocumentNode, ".c:last-child li")); Guid hashKey = GenHashKey(current.Url.OriginalString);
var bo = Crawler.Repository.LoadHouses(hashKey);
bo.SiteID = "Zlhome.com";
bo.PageUrl = current.Url.OriginalString;
bo.CityName = Crawler.Config.CityName;
attrs.FillEntity(bo, new Dictionary<string, string>()
{
{"地址", "小区地址"},
{"所属片区", "所属区域"},
{"物业类型", "物业类别"},
{"骏工日期", "竣工时间"},
});
MapMark(bo);
Repository.Save(bo);
Crawler.OutWrite("保存楼盘 {0}", bo.小区名称); var pNode = QueryNodes(dom.DocumentNode, ".xqinfo").Skip().First();
var dealNode = QueryNode(pNode, "a");
var url = GetHref(dealNode, current.Url);
Crawler.PushUrl(url, DataDepth.Deal, bo.RowID);
}
break;
case DataDepth.Deal:
{
Guid housesID = (Guid)current.State;
var dom = lander.GetDocument(pHandler); bool isRent = false;
foreach (var table in QueryNodes(dom.DocumentNode, ".cjxxtable"))
{
foreach (var node in QueryNodes(table, "tr"))
{
var spans = QueryTexts(node, "td").ToArray();
DateTime? transactionDate = null;
DateTime dump;
if (DateTime.TryParse(spans[], out dump))
{
transactionDate = dump;
}
Repository.SaveHouselisting(new HouselistingEntity()
{
HousesID = housesID,
TransactionDate = transactionDate,
Area = spans[],
Apartment = spans[],
Orientation = spans[],
Floor = spans[],
UnitPriceOrLease = spans[],
SoldPriceOrRent = spans[],
ServiceBroker = spans[],
IsRent = isRent
});
Crawler.OutWrite("保存小区{1}记录 {0}", housesID, isRent ? "出租" : "出售");
}
isRent = true;
}
}
break;
}
}
}
}

zlhome.com Deal的更多相关文章

  1. Dooioo Deal

    using AnfleCrawler.Common; using System; using System.Collections.Generic; using System.Linq; using ...

  2. XML节点名称中有小数点处理(deal with dot)导致使用xpath时报错解决方法

    <?xml version="1.0"?> <ModifyFiles> <_Layout.cshtml>123456</_Layout.c ...

  3. whu 1464 deal with numbers

    WHU 1464  deal with numbers 题意: 给你一串数字,对着串数字有三项操作: Minus a,b,c:对区间[a,b]总的每个数都减c. Division a,b,c:对区间[ ...

  4. OK335xS canutils deal with compile error

    /************************************************************************************** * OK335xS ca ...

  5. 能让你聪明的工作DEAL四法则,来自《每周工作四小时》书籍

    来自书籍<每周工作四小时>,作者蒂莫西·费里斯(Tim Ferriss,昵称:蒂姆)   能让你聪明的工作DEAL四法则: 第一步:D——定位(Definition) 第二步:E——精简( ...

  6. how to deal with EINTR fault

    [how to deal with EINTR fault] EINTR:interupted error.是指一个调用被信号给中断,对于同步的耗时调用来说,这个操作常见,譬如select.read. ...

  7. Spoken English Practice( Believe it or not, I don't need to make believe its a big deal. (believe,deal, You don't say))

    音标复习                                                绿色:连读:红色:略读:蓝色:浊化:橙色:弱读 口语蜕变(2017/6/25) Sorry, t ...

  8. If you want the rainbow, you have to deal with the rain.

    If you want the rainbow, you have to deal with the rain.想要彩虹,就先忍受雨水.

  9. Using SMOTEBoost(过采样) and RUSBoost(使用聚类+集成学习) to deal with class imbalance

    Using SMOTEBoost and RUSBoost to deal with class imbalance from:https://aitopics.org/doc/news:1B9F7A ...

随机推荐

  1. sql server2008 R2 生成带数据的脚本

    目前 sql server2008 R2 版本有这个功能 http://www.cnblogs.com/weisenz/archive/2013/03/20/2971334.html

  2. 遗传算法在JobShop中的应用研究(part 2:编码)

    编码 在上一篇博客中我们讨论了车间调度问题的编码,具体说就是根据工件的个数和每个工件的工序数来生成12122这样的数字排列,具体的说一个工件包含多少道工序,那么这个工件的编号就出现多少次.从12122 ...

  3. [jetbrains系列] 外链第三方库+代码补全设置

    jetbrains系列的IDE真的是太好用了,有种相见恨晚的感觉. 在开发过程中第三方库是必不可少的,在开发的时候如果有一个可以补全的IDE可以节省查文档的时间. 举个例子:给pycharm配pysp ...

  4. JavaScript 获取当前时间戳

    转自博客(http://blog.sina.com.cn/s/blog_8772845101019kg5.html) JavaScript 获取当前时间戳:第一种方法: var timestamp = ...

  5. PHP文本框的值随下拉框改变

    初学PHP,下面是实现文本框内容随下拉框变化的代码实现: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN&q ...

  6. python打怪之路【第一篇】:99乘法表

    需求:实现99乘法表 代码: #!/usr/bin/env python # -*- coding:utf-8 -*- #author chenjing for i in range(10): for ...

  7. spring aop搭建redis缓存

    SpringAOP与Redis搭建缓存 近期项目查询数据库太慢,持久层也没有开启二级缓存,现希望采用Redis作为缓存.为了不改写原来代码,在此采用AOP+Redis实现. 目前由于项目需要,只需要做 ...

  8. nodejs的第二天学习笔记

    一. Shell: 1) 常用的shell a) CMD: window+r 打开面板中输入cmd 回车   特点:很多都是window下面的指令 b) powerShell:   特点:它能够兼容w ...

  9. 【matlab】膨胀

    clear all;close all; BW=zeros(9,10); BW(4:6,4:7) =1 imshow(BW) hold on SE=strel('square',3) BW2=imdi ...

  10. 利用react来制作评论框

    学习地址:https://my.oschina.net/leogao0816/blog/379488