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. 阿里云OneinStack,Linux下tomcat命令

    阿里云OneinStack,Linux下tomcat命令 Linux下如何查看tomcat是否启动在Linux系统下,重启Tomcat使用命令操作的首先,进入Tomcat下的bin目录cd /usr/ ...

  2. LeetCode----326. Power of Three(Java)

    package isPowerOfThree326; /* Given an integer, write a function to determine if it is a power of th ...

  3. Prince2和PMP的区别,大多数人都没有搞清楚!

    [涨姿势]Prince2和PMP的区别,大多数人都没搞清楚!   项目管理领域有2个流行的知识体系:☑ 一个是美国项目管理协会(PMI)开发的"项目管理知识体系(PMBOK,Project ...

  4. MapReduce的模式、算法和用例

    英文原文:<MapReduce Patterns, Algorithms, and Use Cases> https://highlyscalable.wordpress.com/2012 ...

  5. 页面缩放对css的影响

    昨天发现一个上线的项目css样式明显不对,但是查看别人的电脑上的页面样式都是没问题的,于是找了半天原因,原来是我的浏览器对这个页面缩放了,导致样式问题. 发现了页面缩放会作用在同一个域名下的所有页面, ...

  6. zigbee学习之路(三):按键的控制

    一.前言 通过前一次的实验,相信大家都已经对cc2530程序的编写有了一定的认识,这次我们来操作和实验的是cc2530上的按键模块. 二.原理分析 我们先来看一下按键的原理图: 根据原理图我们可以得出 ...

  7. Flowplayer-Skin

    SOURCE URL: https://flowplayer.org/docs/skinning.html Skinning with CSS3 Flowplayer skin design is C ...

  8. CentOS7网卡的命名规则

    一.前两个字符的含义 en 以太网 Ethernet wl 无线局域网 WLAN ww 无线广域网 WWAN 二.第三个字符的含义 o on-board device index number s h ...

  9. js中attr 与find 获取属性值,

    一.attr的用法 1. attr(属性名)        //获取属性的值(取得第一个匹配元素的属性值.通过这个方法可以方便地从第一个匹配元素中获取一个属性的值.如果元素没有相应属性,则返回 und ...

  10. Ubuntu安装SSH服务

    1 SSH服务 Ubuntu默认并没有安装ssh服务,如果通过ssh远程连接到Ubuntu,需要自己手动安装ssh-server(openssh-server). 1.1 检测是否安装SSH服务 出现 ...