GFT_News Auto
using AnfleCrawler.Common;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks; namespace AnfleCrawler.DataAnalyzer
{
internal class GFT_News : AnalyzerBase
{
public override void Init(PageCrawler crawler)
{
// var pHandler = new PageContentHandler()
// {
// Url = new Uri("http://admin.gofangtong.com/Login.aspx"),
// CrossLoad = (arg, xDom) =>
// {
// if (arg.IsRedirect)
// {
// arg.IsRedirect = false;
// return;
// }
// arg.IsRedirect = true;
// var input = xDom.GetElementById("txtusername");
// input.SetAttribute("value", "admin");
// input = xDom.GetElementById("txtuserpass");
// input.SetAttribute("value", "123456");
// var btn = xDom.GetElementById("btnlogin");
// btn.InvokeMember("click");
// }
// };
// Crawler.Lander.GetDocument(pHandler); //crawler.PushUrl(new System.Net.StringPatternGenerator("http://webapi.anfle.com/BMLF/BmlfList?page=[1-75]&rows=50&sort=PublishDate&order=desc"), 0);
base.Init(crawler);
} protected override void AnalyzeInternal(PageLandEntity current)
{
var lander = Crawler.Lander;
var pHandler = CreateContentHandler(current); var dom = lander.GetDocument(pHandler);
string text = dom.DocumentNode.InnerText;
//App.LogInfo("GFT:\r\n\r\n{0}", text);
var json = JObject.Parse(text);
var client = new HttpClient();
client.SendReceiveTimeout = int.MaxValue;
foreach (var item in json["rows"])
{
try
{
string content = System.Web.HttpUtility.UrlEncode(item.Value<string>("CONTENT"));
client.SetRequest(new Uri("http://webapi.anfle.com/BMLF/Match"));
client.Form["content"] = content;
var matchtext = client.GetResponse().GetResponseText();
var mjson = JObject.Parse(matchtext);
var mset = (JArray)mjson["Message"];
var str = new StringBuilder();
var configs = new KeyValuePair<string, string>[]
{
new KeyValuePair<string, string>("CITY_NAME","城市"),
new KeyValuePair<string, string>("STANDARD_REGION","区域"),
new KeyValuePair<string, string>("SHORT_NAME_CHS","企业"),
new KeyValuePair<string, string>("XIANGMUMINGCHENG","项目"),
};
for (int i = ; i < mset.Count; i++)
{
if (mset[i] == null)
{
continue;
}
var c = configs[i];
var thenSet = mset[i].Select(p =>
{
string ext = string.Empty;
if (i == && p["CITY_NAME"] != null)
{
ext = p.Value<string>("CITY_NAME") + "-";
}
return ext + p.Value<string>(c.Key) + "|" + c.Value;
});
if (!thenSet.Any())
{
continue;
}
str.Append(",").Append(string.Join(",", thenSet));
}
string rowid = item.Value<string>("ROWID");
if (str.Length == )
{
Crawler.OutWrite("Skip Empty {0}", rowid);
continue;
} client.SetRequest(new Uri("http://webapi.anfle.com/BMLF/Save"));
client.Form["isModify"] = "true";
client.Form["rowId"] = rowid;
client.Form["val"] = str.ToString();
client.Form["kind"] = item.Value<string>("KIND");
client.Form["title"] = item.Value<string>("TITLE");
client.Form["source"] = item.Value<string>("SOURCE");
client.Form["date"] = item.Value<string>("PUBLISHDATE");
//client.Form["content"] = content;
client.Form["state"] = Convert.ToInt16(Convert.ToBoolean(item.Value<string>("STATE"))).ToString();
string ret = client.GetResponse().GetResponseText();
Crawler.OutWrite("Match OK {0} {1}", rowid, ret);
}
catch (Exception ex)
{
Crawler.OutWrite("Error {0}", ex.Message);
App.LogError(ex, "GFT");
}
}
}
}
}
GFT_News Auto的更多相关文章
- C++11特性——变量部分(using类型别名、constexpr常量表达式、auto类型推断、nullptr空指针等)
#include <iostream> using namespace std; int main() { using cullptr = const unsigned long long ...
- overflow:hidden与margin:0 auto之间的冲突
相对于父容器水平居中的代码margin:0 auto与overflow:hidden之间存在冲突.当这两个属性同时应用在一个DIV上时,在chrome浏览器中将无法居中.至于为啥我也不明白.
- Android Auto开发之一《开始学习Auto 》
共同学习,共同进步, 转载请注明出处.欢迎微信交流:sfssqs,申请注明"Android Car"字样 ================= =================== ...
- width:100%;与width:auto;的区别
<div> <p>1111</p> </div> div{ width:980px; background-color: #ccc; height:30 ...
- SQl 2005 For XMl 简单查询(Raw,Auto,Path模式)(1)
很多人对Xpath可能比较熟悉,但不知道有没有直接操作过数据库,我们都知道 在Sql2005里公支持的几种查询有Raw,Auto模式,页并没有Path和Elements用法等,如果在2000里使用过 ...
- margin:0 auto;不居中
margin:0 auto:不居中可能有以下两个的原因; 1.没有设置宽度<div style="margin:0 auto;"></div>看看上面的代码 ...
- 初学C++ 之 auto关键字(IDE:VS2013)
/*使用auto关键字,需要先赋初值,auto关键字是会根据初值来判断类型*/ auto i = ; auto j = ; cout << "auto i = 5" & ...
- C++11 - 类型推导auto关键字
在C++11中,auto关键字被作为类型自动类型推导关键字 (1)基本用法 C++98:类型 变量名 = 初值; int i = 10; C++11:auto 变量名 = 初值; auto i ...
- 为什么 "auto a = 1;" 在C语言中可以编译通过?
参照:这里 这让我想起之前看的一部书, int i; 其实是等价与 auto int i; 表示为局部变量 这应该与static是相对的吧?
随机推荐
- s3c2440 移值新内核 linux-4.1.36
arm-linuxgcc version 4.3.2 经过试验,最高可以编译到 linux-4.1.36 ,在高的版本会有错误 ,可能是 GCC 编译器版本较低造成. 解压比较麻烦还要装一个 xz x ...
- Oracle数据库DOC命令导入导出(2014-3-10记)
导出:exp lwj/lwj123456@orcl file=d:/db.dmp full=y 导入:imp lwj/lwj123456@orcl file=d:/db.dmp full=y 注:用户 ...
- Java 多线程处理[全]
http://blog.csdn.net/ghsau/article/details/7421217 Java线程(一):线程安全与不安全 http://blog.csdn.net/ghsau/art ...
- noi 9271 奶牛散步
题目链接:http://noi.openjudge.cn/ch0206/9271/ 同noi 踩方格,但是题目有问题,%12345,我也是看了discuss才知道的. #include <bit ...
- php数组插入数据库这个功能该怎么实现
原文网址:https://segmentfault.com/q/1010000004048449 比如一个数组$a=array("a"=>"1",&quo ...
- Linux 2.6内核Makefile浅析
1 概述 Makefile由五个部分组成: Makefile:根目录Makefile,它读取.config文件,并负责创建vmlinux(内核镜像)和modules(模块文件). .config:内核 ...
- java并发编程参考资料
1.java编程思想 2.java并发编程实战 3.java并发编程的艺术 4.http://www.infoq.com/cn/author/%E7%A8%8B%E6%99%93%E6%98%8E#文 ...
- Flowplayer-Embedding
SOURCE URL:https://flowplayer.org/docs/embedding.html Embedding Video embedding is an act where the ...
- java第三章动手动脑
public class InitializeBlockDemo { /** * @param args */ public static void main(String[] args) { Ini ...
- CSS3的chapter6
CSS布局 div标签: 在css布局方式中,div 是这种布局方式的核心对象,我们的页面排版不再依赖于表格, 仅从div的使用上说,做一个简单的布局只需要两样东西:div 与 cs ...