c# 微信模拟登录抓取公共帐号发送图文信息

using System;
using System.Collections.Generic;
using System.Web;
using System.IO;
using System.Net;
using System.Security.Cryptography;
using System.Text;
using System.Security.Cryptography.X509Certificates;
using System.Net.Security;
using System.Runtime.Serialization;
using LitJson;
using System.Drawing;
using System.Drawing.Imaging;
using Dejun.DataProvider;
using Dejun.DataProvider.Table;
using Dejun.DataProvider.Sql2005;

/// <summary>
/// weixinLogin 的摘要说明
/// </summary>
public class weixinLogin
{
	public weixinLogin()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
	}
    public static CookieContainer cc = new CookieContainer();
    public static string Tonken = "";


    public static string Gethtml(string username,string pwd)
    {
        string html = "";

        ExecLogin("http://mp.weixin.qq.com/cgi-bin/login?lang=zh_CN", username, pwd);

        html = Getweixin("https://mp.weixin.qq.com/cgi-bin/masssendpage?t=mass/list&action=history&begin=0&count=1000&token=" + Tonken + "&lang=zh_CN");
        if (html.IndexOf("wx.cgiData") > -1)
        {
            html = html.Replace("\r", "").Replace("\n", "").Replace("<br>","") ;
            html = SubString1(html, "list : (", ").msg_item");
       
        JsonData json = JsonMapper.ToObject(html);
        JsonData jditems = json["msg_item"];
        int itemcount = jditems.Count;
        foreach( JsonData item in jditems )
        {
            string tuwen = item.ToJson();
            
            string content = "";
            string title = "";
            if (tuwen.IndexOf("content_url") > -1)
            {
                string url = (String)item["content_url"];//获取url
                 title = (String)item["title"];//信息标题
                string str = Getweixin(url);//获取单条信息内容页
                content = SubString1(str, "<div id=\"page-content\" class=\"page-content\">", "<p class=\"page-toolbar\">"); //信息内容
                if (content.IndexOf("<div class=\"media\" id=\"media\">") > -1)
                {
                    string fristpic = SubString1(content, "<div class=\"media\" id=\"media\">", "<div class=\"text\">");
                    string tihuan = SubString1(fristpic, "<img", "data-src");
                    content = content.Replace(tihua
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值