------ #### V1.0.2404.1201 - 新增支持手动运行规则。 - 规则播放时间间隔不再针对全局声效,而只针对当前规则声效。 - 修复规则中播放文件夹可能导致无法执行的BUG。 - 修复规则不勾选礼物和点赞,则无法执行的BUG。
122 lines
3.6 KiB
C#
122 lines
3.6 KiB
C#
using DotNet4.Utilities;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace LiveTools
|
|
{
|
|
public class RyPostGet
|
|
{
|
|
/// <summary>
|
|
/// 以post方式获取网页源码
|
|
/// </summary>
|
|
/// <param name="url"></param>
|
|
/// <param name="post"></param>
|
|
/// <param name="cookie"></param>
|
|
/// <returns></returns>
|
|
public HttpResult Post(string url, string post, string cookie)
|
|
{
|
|
try
|
|
{
|
|
HttpHelper t = new HttpHelper();
|
|
HttpItem m = new HttpItem()
|
|
{
|
|
URL = url,
|
|
Postdata = post,
|
|
ContentType = "application/x-www-form-urlencoded",
|
|
Method = "POST",
|
|
Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
|
|
Expect100Continue = false
|
|
};
|
|
if (cookie != "")
|
|
{
|
|
m.Cookie = cookie;
|
|
}
|
|
HttpResult r = t.GetHtml(m);
|
|
return r;
|
|
}
|
|
catch
|
|
{
|
|
HttpResult r = new HttpResult();
|
|
return r;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 以post方式获取网页源码
|
|
/// </summary>
|
|
/// <param name="url"></param>
|
|
/// <param name="post"></param>
|
|
/// <returns></returns>
|
|
public HttpResult Post(string url, string post)
|
|
{
|
|
return Post(url, post, cookie);
|
|
}
|
|
/// <summary>
|
|
/// 获取网页源码
|
|
/// </summary>
|
|
/// <param name="url"></param>
|
|
/// <param name="cookie"></param>
|
|
/// <returns></returns>
|
|
public HttpResult Get(string url, string cookie)
|
|
{
|
|
try
|
|
{
|
|
HttpHelper t = new HttpHelper();
|
|
HttpItem m = new HttpItem()
|
|
{
|
|
URL = url
|
|
};
|
|
if (cookie != "")
|
|
{
|
|
m.Cookie = cookie;
|
|
}
|
|
m.Allowautoredirect = true;
|
|
HttpResult r = t.GetHtml(m);
|
|
return r;
|
|
}
|
|
catch
|
|
{
|
|
HttpResult r = new HttpResult();
|
|
return r;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 获取网页源码
|
|
/// </summary>
|
|
/// <param name="url"></param>
|
|
/// <returns></returns>
|
|
public HttpResult Get(string url)
|
|
{
|
|
return Get(url, cookie);
|
|
}
|
|
public string Cookie
|
|
{
|
|
get { return cookie; }
|
|
set { cookie = value; }
|
|
}
|
|
private string cookie = "";
|
|
public static string UrlEncode(string str)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
byte[] byStr = System.Text.Encoding.UTF8.GetBytes(str); //默认是System.Text.Encoding.Default.GetBytes(str)
|
|
for (int i = 0; i < byStr.Length; i++)
|
|
{
|
|
sb.Append(@"%" + Convert.ToString(byStr[i], 16));
|
|
}
|
|
|
|
return (sb.ToString());
|
|
}
|
|
public static string GetMD5(string str)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
foreach (byte b in System.Security.Cryptography.MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(str)))
|
|
{
|
|
sb.Append(b.ToString("X2"));
|
|
}
|
|
return sb.ToString().Trim();
|
|
}
|
|
}
|
|
}
|