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网络爬虫抓取微信好友的所 ...
随机推荐
- ICEM-圆柱与长方体相切
原视频下载地址:https://yunpan.cn/cqvgLe39ZU4Ke 访问密码 c1c9
- Mac搭建C语言环境
Mac搭建C语言环境 创建一个工程目录 /Users/chennan/cproject 配置sublime运行环境 打开sublime text3,通过下面的步骤一次点击 Tools(工具)-> ...
- Python3中转换字符串编码
在使用subprocess调用Windows命令时,遇到了字符串不显示中文的问题,源码如下:#-*-coding:utf-8-*-__author__ = '$USER' #-*-coding:utf ...
- 性能测试工具gperftools使用
https://blog.csdn.net/10km/article/details/83820080 https://blog.51cto.com/wulingdong/2043898 https: ...
- boost 介绍
简介: Boost库是一个可移植.提供源代码的C++库,作为标准库的后备,是C++标准化进程的开发引擎之一. Boost库由C++标准委员会库工作组成员发起,其中有些内容有望成为下一代C++标准库内容 ...
- 如何确认oracle客户端中的TNSNAMES中的service_name
在我们安装oracle的客户端,或者PLSQL develop的时候,需要在oracle的安装目录下修改TNSNAME中配置你要连接的数据库的TNS参数.配置好了可以通过命令行使用tnsping命令测 ...
- LC 990. Satisfiability of Equality Equations
Given an array equations of strings that represent relationships between variables, each string equa ...
- 123457123457#0#-----com.threeapp.PaoPaoLong01-----泡泡龙大作战01
com.threeapp.PaoPaoLong01-----泡泡龙大作战01
- jQuery BlockUI Plugin Demo 6(Options)
Options BlockUI's default options look (exactly) like this: // override these in your code to change ...
- 【CUDA开发】CUDA编程接口(一)------一十八般武器
子曰:工欲善其事,必先利其器.我们要把显卡作为通用并行处理器来做并行算法处理,就得知道CUDA给我提供了什么样的接口,就得了解CUDA作为通用高性能计算平台上的一十八般武器.(如果你想自己开发驱动,自 ...