asp.net MVC 抓取微信文章数据(正文)
1.抓微信的正文主要是调用第三方的接口(https://market.aliyun.com/products/56928004/cmapi012134.html)
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks; namespace QBSqlServer.GSDataAPIs.GetHtml
{
public class WeChatPublicNumberQueryAPI
{
private const String host = "https://ali-weixin.showapi.com";
private const String path = "/582-9";
private const String method = "GET";
private const String appcode = "你自己的appcode"; public static Root GetWeChathtml(string title)
{
string outhtml = string.Empty;
string t = System.Web.HttpUtility.UrlEncode(title);
//String querys = "needComment=0&needContent=1&url=url";
String querys = "needContent=1&url=" + t;
String bodys = "";
String url = host + path;
HttpWebRequest httpRequest = null;
HttpWebResponse httpResponse = null; if ( < querys.Length)
{
url = url + "?" + querys;
} if (host.Contains("https://"))
{
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
}
else
{
httpRequest = (HttpWebRequest)WebRequest.Create(url);
}
httpRequest.Method = method;
httpRequest.Headers.Add("Authorization", "APPCODE " + appcode);
if ( < bodys.Length)
{
byte[] data = Encoding.UTF8.GetBytes(bodys);
using (Stream stream = httpRequest.GetRequestStream())
{
stream.Write(data, , data.Length);
}
}
try
{
httpResponse = (HttpWebResponse)httpRequest.GetResponse();
}
catch (WebException ex)
{
httpResponse = (HttpWebResponse)ex.Response;
} Console.WriteLine(httpResponse.StatusCode);
Console.WriteLine(httpResponse.Method);
Console.WriteLine(httpResponse.Headers);
Stream st = httpResponse.GetResponseStream();
StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
string strResult = reader.ReadToEnd();
Root jobInfoList = JsonConvert.DeserializeObject<Root>(strResult);
Console.WriteLine(reader.ReadToEnd());
Console.WriteLine("\n");
return jobInfoList;
} public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
return true;
}
} public class Showapi_res_body
{
/// <summary>
///
/// </summary>
public string newUrl { get; set; }
/// <summary>
///
/// </summary>
public string date { get; set; }
/// <summary>
///
/// </summary>
public string weixinNum { get; set; }
/// <summary>
/// 这是正文的html
/// </summary>
public string content { get; set; }
/// <summary>
///
/// </summary>
public string ret_code { get; set; }
/// <summary>
/// 秀场|中国品牌ELLASSAY米兰时装周首秀!
/// </summary>
public string title { get; set; }
/// <summary>
///
/// </summary>
public string contentImg { get; set; }
/// <summary>
///
/// </summary>
public string userLogo { get; set; }
/// <summary>
///
/// </summary>
public string oldUrl { get; set; }
/// <summary>
/// 徐峰立
/// </summary>
public string userName { get; set; }
/// <summary>
///
/// </summary>
public string read_num { get; set; }
/// <summary>
///
/// </summary>
public string like_num { get; set; }
/// <summary>
///
/// </summary>
public string userLogo_code { get; set; }
} public class Root
{
/// <summary>
///
/// </summary>
public string showapi_res_code { get; set; }
/// <summary>
///
/// </summary>
public string showapi_res_error { get; set; }
/// <summary>
///
/// </summary>
public Showapi_res_body showapi_res_body { get; set; }
}
}
asp.net MVC 抓取微信文章数据(正文)的更多相关文章
- asp.net mvc抓取微信文章里面所有的图片
/// <summary> /// 下载指定URL下的所有图片 /// </summary> public class WebPageImage { /// <summa ...
- asp.net mvc 抓取京东商城分类
555 asp.net mvc 抓取京东商城分类 URL:http://www.jd.com/allSort.aspx 效果: //后台代码 public ActionResult Get ...
- [Python爬虫] 之十五:Selenium +phantomjs根据微信公众号抓取微信文章
借助搜索微信搜索引擎进行抓取 抓取过程 1.首先在搜狗的微信搜索页面测试一下,这样能够让我们的思路更加清晰 在搜索引擎上使用微信公众号英文名进行“搜公众号”操作(因为公众号英文名是公众号唯一的,而中文 ...
- 使用redis所维护的代理池抓取微信文章
搜狗搜索可以直接搜索微信文章,本次就是利用搜狗搜搜出微信文章,获得详细的文章url来得到文章的信息.并把我们感兴趣的内容存入到mongodb中. 因为搜狗搜索微信文章的反爬虫比较强,经常封IP,所以要 ...
- 如何利用Python网络爬虫抓取微信好友数量以及微信好友的男女比例
前几天给大家分享了利用Python网络爬虫抓取微信朋友圈的动态(上)和利用Python网络爬虫爬取微信朋友圈动态——附代码(下),并且对抓取到的数据进行了Python词云和wordart可视化,感兴趣 ...
- Charles抓取微信小程序数据 以及 其它应用网站数据
为了抓取小程序数据所以使用Charles来抓取,下面介绍下使用方法(mac环境下使用).使用Charles可以非常方便的抓取Http/Https请求.官方dmg下载地址:点击此处下载 Charles抓 ...
- 使用Fiddler抓取微信饿了么小程序数据
使用Fiddler抓取微信饿了么小程序数据 准备 一部装载Android 7.0以下的手机:此处使用华为荣耀5x 微信小程序7.0以下版本:此处为6.6.7.此处可通过豌豆荚应用下载. 安装好的Fid ...
- 如何利用Python网络爬虫抓取微信朋友圈的动态(上)
今天小编给大家分享一下如何利用Python网络爬虫抓取微信朋友圈的动态信息,实际上如果单独的去爬取朋友圈的话,难度会非常大,因为微信没有提供向网易云音乐这样的API接口,所以很容易找不到门.不过不要慌 ...
- 利用Python网络爬虫抓取微信好友的签名及其可视化展示
前几天给大家分享了如何利用Python词云和wordart可视化工具对朋友圈数据进行可视化,利用Python网络爬虫抓取微信好友数量以及微信好友的男女比例,以及利用Python网络爬虫抓取微信好友的所 ...
随机推荐
- UNIX网络编程 环境搭建
配置好动态链接库或者静态链接库 1,下载UNIX网络编程书的头文件及示例源码unpv13e 2 按照readme来编译 Execute the following from the src/ d ...
- final和finally的区别
final关键字可以用于修饰类,方法,变量.用该关键字修饰类,方法,变量都有不可变的特性. 1)final关键字用于基本数据类型前,就表明该变量就变成了一个常量,在被定义后的赋值不能被修改. 2)fi ...
- 胜利点 选题 Scrum立会报告+燃尽图 02
此作业要求参见[https://edu.cnblogs.com/campus/nenu/2019fall/homework/8683] 一.小组介绍 组长:贺敬文 组员:彭思雨 王志文 位军营 杨萍 ...
- Code First 迁移----官方 应用程序启动时自动升级(MigrateDatabaseToLatestVersion 初始值设定项)
Code First 迁移 如果使用的是 Code First 工作流,推荐使用 Code First 迁移改进应用程序的数据库架构. 迁移提供一组允许以下操作的工具: 创建可用于 EF 模型的初始数 ...
- oracle中的trigger
https://blog.csdn.net/indexman/article/details/8023740/ https://www.cnblogs.com/sharpest/p/7764660.h ...
- Matlab图像处理——中值滤波medfilt2问题解决
本文链接:https://blog.csdn.net/Pxzly1117/article/details/79201772程序: I=imread('13.jpg');%读入图像imshow(I);h ...
- vlookup实战_英语单词更新
https://study.163.com/provider/400000000398149/index.htm?share=2&shareId=400000000398149( 欢迎关注博主 ...
- unless it is in a subquery contained in a HAVING clause or a select list.
sql查询报错: An aggregate may not appear in the WHERE clause unless it is in asubquery contained in a HA ...
- <JavaScript>尺寸类样式的获取
尺寸类样式的获取 offsetHeight HTMLElement.offsetHeight 是一个只读属性,它返回该元素的像素高度,高度包含该元素的垂直内边距和边框,且是一个整数.(content+ ...
- 123457------com.threeapp.quWeiKaTongPinTu01----趣味卡通拼图游戏
com.threeapp.quWeiKaTongPinTu01----趣味卡通拼图游戏