Commit 3348d752 authored by 黄奎's avatar 黄奎

1111

parent c8f33476
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using VTX.FW.Helper;
namespace EduSpider.Utility
{
/// <summary>
......@@ -15,12 +17,12 @@ namespace EduSpider.Utility
/// <summary>
/// 域名
/// </summary>
private static string domain = "https://console.eeo.cn/saasajax";
private static string domain = "https://console.eeo.cn";
/// <summary>
/// Cookie
/// </summary>
private static string Cookie = "sajssdk_2015_cross_new_user=1; _eeos_uid=12780052; _eeos_useraccount=18140082327; _eeos_userlogo=%2Fupload%2Fimages%2F20200126%2F709df9532bee722f2268_70.jpg; _eeos_domain=.eeo.cn; _eeos_remember=1; _eeos_traffic=EqlIOFq4S2hz5FTTtHzNUViBYcWCixrJYMCF6Y5yJuD8eq8ZwPvVSHMvUkLFA5lzNoaTrDBpGhG4CE5Tjuw%2BomVQCAXfwH%2BefAyKrRMPc3g%3D; _eeos_sid=12780052; _eeos_nsid=kspGu2gfMu%2BU2EFgLpSGyg%3D%3D; locationArgumentLang=zh-CN; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%2212780052%22%2C%22first_id%22%3A%22180f54ced3048f-02eaffc35f728a-3e604809-2073600-180f54ced316ee%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E8%87%AA%E7%84%B6%E6%90%9C%E7%B4%A2%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC%22%2C%22%24latest_referrer%22%3A%22https%3A%2F%2Fwww.baidu.com%2Flink%22%7D%2C%22%24device_id%22%3A%22180f54ced3048f-02eaffc35f728a-3e604809-2073600-180f54ced316ee%22%7D; PHPSESSID=sd33g5i5ta97b7a8d19vld71q2; __tk_id=0a89552a4b2a69f62bc9ad086c6402e1";
private static string Cookie = "sajssdk_2015_cross_new_user=1; _eeos_uid=12780052; _eeos_useraccount=18140082327; _eeos_userlogo=%2Fupload%2Fimages%2F20200126%2F709df9532bee722f2268_70.jpg; _eeos_domain=.eeo.cn; _eeos_remember=1; _eeos_sid=12780052; _eeos_nsid=kspGu2gfMu%2BU2EFgLpSGyg%3D%3D; locationArgumentLang=zh-CN; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%2212780052%22%2C%22first_id%22%3A%22180f54ced3048f-02eaffc35f728a-3e604809-2073600-180f54ced316ee%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E8%87%AA%E7%84%B6%E6%90%9C%E7%B4%A2%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC%22%2C%22%24latest_referrer%22%3A%22https%3A%2F%2Fwww.baidu.com%2Flink%22%7D%2C%22%24device_id%22%3A%22180f54ced3048f-02eaffc35f728a-3e604809-2073600-180f54ced316ee%22%7D; PHPSESSID=sd33g5i5ta97b7a8d19vld71q2; _eeos_traffic=EqlIOFq4S2hz5FTTtHzNUViBYcWCixrJYMCF6Y5yJuD8eq8ZwPvVSHMvUkLFA5lzNoaTrDBpGhG4CE5Tjuw%2BoopXDRdN9nKnHSmUXCAcxBc%3D; __tk_id=b4b34f64cb5bff7ce317c0caa7c33ced";
/// <summary>
/// 类型
......@@ -33,22 +35,92 @@ namespace EduSpider.Utility
/// <returns></returns>
public static string GetClassQuery()
{
string url = "/course.ajax.php?action=getCourseList";
string url = "/saasajax/course.ajax.php?action=getCourseList";
string ApiUrl = domain + url;
string apiResult = HttpPost(ApiUrl, "", contentType:contentType, cookie: Cookie);
if (!string.IsNullOrWhiteSpace(apiResult))
Dictionary<string, object> dic = new Dictionary<string, object>()
{
{ "page",1},
{ "perpage",20},
{ "courseState",1},
};
string result = "";
try
{
JObject rootObj = JObject.Parse(apiResult);
int PageSize = rootObj.GetInt("PageSize");
int PageCount= rootObj.GetInt("PageCount");
Encoding encoding = Encoding.UTF8;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(ApiUrl);
request.Method = "POST";
request.Accept = "application/json, text/plain, */*";
request.Headers.Add("accept-encoding", "gzip");
request.Headers.Add("accept-language", "zh-CN,zh;q=0.9");
request.ContentType = "application/json; charset=utf-8";
if (!string.IsNullOrWhiteSpace(Cookie))
{
request.Headers.Add("cookie", Cookie);
}
request.Headers.Add("origin", "https://console.eeo.cn");
request.Referer = "https://console.eeo.cn/saas/school/index.html";
request.Headers.Add("sec-ch-ua", "Not A;Brand'; v = '99', 'Chromium'; v = '101', 'Google Chrome'; v = '101'");
request.Headers.Add("sec-ch-ua-mobile", "?0");
request.Headers.Add("sec-ch-ua-platform", "Windows");
return apiResult;
request.Headers.Add("sec-fetch-dest", "empty");
request.Headers.Add("sec-fetch-mode", "cors");
request.Headers.Add("sec-fetch-site", "same-origin");
request.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36");
byte[] buffer = encoding.GetBytes(JsonHelper.Serialize(dic));
request.ContentLength = buffer.Length;
request.GetRequestStream().Write(buffer, 0, buffer.Length);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using StreamReader reader = new StreamReader(response.GetResponseStream(), encoding);
result = reader.ReadToEnd();
Console.WriteLine("result:" + result);
}
catch (WebException ex)
{
LogHelper.WriteError("HttpPost", string.Format("HttpHelper_HttpPost"), ex: ex);
}
return result;
public static string GetData(string url)
}
public static string GetTKId()
{
return "";
string url = "https://errmon.eeo.cn/api/13/envelope";
string result = "";
try
{
Encoding encoding = Encoding.UTF8;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.Accept = "application/json, text/plain, */*";
request.ContentType = "application/json; charset=utf-8";
request.Headers.Add("origin", "https://console.eeo.cn");
request.Headers.Add("referer", "https://console.eeo.cn/");
request.Headers.Add("sec-fetch-dest", "empty");
request.Headers.Add("sec-fetch-mode", "cors");
request.Headers.Add("sec-fetch-site", "same-origin");
request.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36");
var obj = new
{
sentry_key = "ba90e46c0e4641c190fbc94f84f9cd53",
sentry_version = 7
};
byte[] buffer = encoding.GetBytes(JsonHelper.Serialize(obj));
request.ContentLength = buffer.Length;
request.GetRequestStream().Write(buffer, 0, buffer.Length);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using StreamReader reader = new StreamReader(response.GetResponseStream(), encoding);
result = reader.ReadToEnd();
}
catch (WebException ex)
{
LogHelper.WriteError("HttpPost", string.Format("HttpHelper_HttpPost:url:{0} body:{1} contentType:{2}", url, "", contentType), ex: ex);
}
return result;
}
......@@ -68,7 +140,7 @@ namespace EduSpider.Utility
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.Accept = "application/json, text/javascript, */*";
request.Accept = "application/json, text/plain, */*";
request.ContentType = "application/json; charset=utf-8";
if (contentType != "")
{
......
......@@ -23,9 +23,7 @@ namespace EduSpider.WebApi.Controllers
public ApiResult GetCoursePage()
{
string roomApi = "api/Classroom/Query";
string classQuery = "api/Class/Query";
string str = Utility.HttpHelper.GetData(classQuery);
string str = Utility.HttpHelper.GetClassQuery();
return ApiResult.Success(data: str, message: "成功!");
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment