BaiduMap Search List
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的更多相关文章
- BaiduMap开发,获取公交站点信息。
可能有些人会出现无法导入overlayutil的错误,这是因为BaiduMap里面的包把这部分删除掉了,并且官方没有给出说明,这个地方以前也是让我折腾了很久. 不知道现在有没有说明这个问题,如果需要这 ...
- [数据结构]——二叉树(Binary Tree)、二叉搜索树(Binary Search Tree)及其衍生算法
二叉树(Binary Tree)是最简单的树形数据结构,然而却十分精妙.其衍生出各种算法,以致于占据了数据结构的半壁江山.STL中大名顶顶的关联容器--集合(set).映射(map)便是使用二叉树实现 ...
- Leetcode 笔记 99 - Recover Binary Search Tree
题目链接:Recover Binary Search Tree | LeetCode OJ Two elements of a binary search tree (BST) are swapped ...
- Leetcode 笔记 98 - Validate Binary Search Tree
题目链接:Validate Binary Search Tree | LeetCode OJ Given a binary tree, determine if it is a valid binar ...
- 基于WebGL 的3D呈现A* Search Algorithm
http://www.hightopo.com/demo/astar/astar.html 最近搞个游戏遇到最短路径的常规游戏问题,一时起兴基于HT for Web写了个A*算法的WebGL 3D呈现 ...
- Leetcode: Convert sorted list to binary search tree (No. 109)
Sept. 22, 2015 学一道算法题, 经常回顾一下. 第二次重温, 决定增加一些图片, 帮助自己记忆. 在网上找他人的资料, 不如自己动手. 把从底向上树的算法搞通俗一些. 先做一个例子: 9 ...
- [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 ...
- [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 ...
- [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 ...
随机推荐
- html+css创建提示框
看到下面的效果了吗? 本来我们站点是用下面的图片做的背景, 但是后期当更改完框中的提示内容,并且更新内容较多的时候,发现内容溢出了,如下图: 但是背景图片不能自动拉伸,还得重新做一张背景图,这样就导致 ...
- oracle 金额格式化
一般金额要显示成 XXX,XXX,XXX.XX的格式,可以这样做: to_char(column, 'FM999,999,999,990.00')
- App.xaml.cs
using System.Windows; namespace HelloWorld { /// <summary> /// Interaction logic for App.xaml ...
- sql注入过滤的公共方法
/// <summary> ///SQL注入过滤 /// </summary> /// <param name="InText">要过滤的字符串 ...
- hadoop2.0初识1.2
1 hadoop启动方式(三种) 1.1 各个服务组件逐一启动 *dfs hadoop-daemon.sh start|stop namenode|datanode|secondarynamenode ...
- 如何将php的错误输出到nginx的error_log中去
参考文档:http://www.cnblogs.com/glory-jzx/p/3966082.html 通过FastCGI运行的PHP,在用户访问时出现错误,会首先写入到PHP的errorlog中如 ...
- [Oracle] SQL*Loader 详细使用教程(3)- 控制文件
控制文件是SQL*Loader里最重要的文件,它是一个文本文件,用来定义数据文件的位置.数据的格式.以及配置数据加载过程的行为,在sqlldr中以control参数指定控制文件. 在控制文件里配置 ...
- C语言细节——献给初学者(二)
C语言细节——献给初学者(二) 主题 循环运用+选择判断 C语言循环有for和while/do...while: 选择判断有:if...else和switch...case 在循环中需要注意搭配br ...
- Oracle重做日志文件
一.联机重做日志的规划管理 1.联机重做日志 记录了数据的所有变化(DML,DDL或管理员对数据所作的结构性更改等) 提供恢复机制(对于意外删除或宕机利用日志文件实现数据恢复) 可以被分组管理 11 ...
- nginx虚拟主机配置
nginx虚拟主机配置 虚拟主机的概念虚拟主机,就是把一台物理服务器划分成多个"虚拟"的服务器,每一个虚拟主机都可以有独立的域名和独立的目录nginx虚拟主机的配置nginx的 ...