using AnfleCrawler.Common;
using HtmlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace AnfleCrawler.DataAnalyzer
{
internal class BMap : AnalyzerBase
{
public override void Init(PageCrawler crawler)
{
base.Init(crawler); crawler.PushUrl(new Uri("http://map.baidu.com/"), );
} protected override void AnalyzeInternal(PageLandEntity current)
{
using (var client = new CrossClient())
{
var content = new System.Net.HttpRequestContent();
content.Headers[System.Net.HttpRequestHeader.UserAgent] = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36";
//ScriptingContext.FillAjaxBlock(content.Form, new AjaxBlockEntity[]
//{
// new AjaxBlockEntity()
// {
// ID="", // }
//});
client.Navigate(current.Url, content); client.CurrentInvoke(@" (function () {
$('#PoiSearch').val('青浦 企业');
$('#poiSearchBtn').click();
})();");
System.Threading.Thread.Sleep(); using (var writer = new System.IO.StreamWriter(App.CombinePath("out.txt"), true, Encoding.UTF8))
{
start:
string html = client.CurrentGetHtml();
var dom = new HtmlAgilityPack.HtmlDocument();
dom.LoadHtml(html);
try
{
foreach (var tr in QueryNodes(dom.DocumentNode, "#POI_TABLE_LST tr[id]"))
{
string title = QueryTexts(tr, ".poiTitleW").First();
string addr = QueryTexts(tr, ".n_p_lineheight").First();
string attrVal = QueryAttrs(tr, ".p_left a:first-child", "onclick").First();
attrVal = attrVal.Split(';')[];
int s = attrVal.IndexOf("{"), e = attrVal.LastIndexOf("}");
string sJson = attrVal.Substring(s, e - s + ).Replace("<br/>", "|");
var json = Newtonsoft.Json.Linq.JObject.Parse(sJson); writer.Write("{0},{1},{2}", json.Value<string>("title"), json.Value<string>("content"), json.Value<string>("point"));
writer.WriteLine();
writer.Flush();
//SyncMgr.goFav({'point':'13494514.14|3640372','uid':'ca38818c8f551ef049fd3f9b','cityCode':'289','title':'新朋联众汽车零部件公司','content':'地址:华卫路29<br/>','panoGuid':''});
Crawler.OutWrite(json.Value<string>("title"));
}
}
catch (HtmlNodeMissingException ex)
{
App.LogInfo("HtmlNodeMissing:{0}\r\n{1}", ex.Selector, html);
Crawler.OutWrite("HtmlNodeMissing:{0}", ex.Selector);
goto start;
}
client.CurrentInvoke(@" (function () {
$('#result_page_c a:last').click();
})();");
System.Threading.Thread.Sleep();
goto start;
}
}
}
}
}

BaiduMap Search List的更多相关文章

  1. BaiduMap开发,获取公交站点信息。

    可能有些人会出现无法导入overlayutil的错误,这是因为BaiduMap里面的包把这部分删除掉了,并且官方没有给出说明,这个地方以前也是让我折腾了很久. 不知道现在有没有说明这个问题,如果需要这 ...

  2. [数据结构]——二叉树(Binary Tree)、二叉搜索树(Binary Search Tree)及其衍生算法

    二叉树(Binary Tree)是最简单的树形数据结构,然而却十分精妙.其衍生出各种算法,以致于占据了数据结构的半壁江山.STL中大名顶顶的关联容器--集合(set).映射(map)便是使用二叉树实现 ...

  3. Leetcode 笔记 99 - Recover Binary Search Tree

    题目链接:Recover Binary Search Tree | LeetCode OJ Two elements of a binary search tree (BST) are swapped ...

  4. Leetcode 笔记 98 - Validate Binary Search Tree

    题目链接:Validate Binary Search Tree | LeetCode OJ Given a binary tree, determine if it is a valid binar ...

  5. 基于WebGL 的3D呈现A* Search Algorithm

    http://www.hightopo.com/demo/astar/astar.html 最近搞个游戏遇到最短路径的常规游戏问题,一时起兴基于HT for Web写了个A*算法的WebGL 3D呈现 ...

  6. Leetcode: Convert sorted list to binary search tree (No. 109)

    Sept. 22, 2015 学一道算法题, 经常回顾一下. 第二次重温, 决定增加一些图片, 帮助自己记忆. 在网上找他人的资料, 不如自己动手. 把从底向上树的算法搞通俗一些. 先做一个例子: 9 ...

  7. [LeetCode] Closest Binary Search Tree Value II 最近的二分搜索树的值之二

    Given a non-empty binary search tree and a target value, find k values in the BST that are closest t ...

  8. [LeetCode] Closest Binary Search Tree Value 最近的二分搜索树的值

    Given a non-empty binary search tree and a target value, find the value in the BST that is closest t ...

  9. [LeetCode] Verify Preorder Sequence in Binary Search Tree 验证二叉搜索树的先序序列

    Given an array of numbers, verify whether it is the correct preorder traversal sequence of a binary ...

随机推荐

  1. mongo的安装

    windows: 1 安装scons (1): 下载python2.7, 使用x86_32位,因为scons只有32位安装包可用, http://www.python.org/download/rel ...

  2. 认真分析mmap:是什么 为什么 怎么用【转】

    转自:http://www.cnblogs.com/huxiao-tee/p/4660352.html?utm_source=tuicool&utm_medium=referral 阅读目录 ...

  3. GAT2.0使用文档(组合接口测试)

    3.2接口用例场景组件 在此之前,大家应该都已经开发完成了一个最简单的接口测试用例,但是之前的接口用例的期望结果是固定值,不能动态的去做对比,有很大局限性.下面开始介绍怎样通过场景组件来动态对测试结果 ...

  4. 【转】本地存储-localStroage/sessionStorage存储

    原文地址:[js学习笔记-103]----本地存储-localStroage/sessionStorage存储 客户端存储 l  WEB存储 web存储最初作为html5的一部分被定义成API形式,但 ...

  5. netbeans中给jpanl添加背景图片制定代码的理解——匿名内部类继承父类

    此测试是为了仿照在netbeans中给jpanl添加背景图片的制定代码的执行过程 在JpDemo中定义了个Car类的数据类型,但在给其赋值对象时使用了匿名内部类,继承了Car类,是其子类,并重写了父类 ...

  6. PHP计算时间差,并返回什么时间之前发表的内容

    <?php header("Content-type: text/html; charset=utf-8"); function time2Units ($time){ $y ...

  7. Codeforce 567D

    One-Dimensional Battle Ships time limit per test 1 second memory limit per test 256 megabytes input ...

  8. Normalize.css 初识

    一. 用来干嘛的 一个现代的.准备好了支持 HTML5 技术,并且要替代 CSS Reset 处理样式的理念. Normalize.css 使浏览器渲染所有元素更加一致,并且符合现代标准.它只是针对那 ...

  9. Android study first ----------安卓项目目录结构及adb指令

    #Android项目的目录结构 * Activity:应用被打开时显示的界面 * src:项目代码 * R.java:项目中所有资源文件的资源id * Android.jar:Android的jar包 ...

  10. C\C++ 获取当前路径

    C\C++ 获取当前路径   获取当前工作目录是使用函数:getcwd.cwd指的是“current working directory”,这样就好记忆了. 函数说明: 函数原型:char* getc ...