Commit 872484ac authored by 黄奎's avatar 黄奎

页面修改

parent ba288237
...@@ -10,20 +10,31 @@ namespace EduSpider.Utility ...@@ -10,20 +10,31 @@ namespace EduSpider.Utility
/// </summary> /// </summary>
public class HttpHelper public class HttpHelper
{ {
/// <summary>
/// 创建HttpClient
/// </summary>
/// <param name="cookie"></param>
/// <returns></returns>
public static HttpClient GenerateHttp(string cookie) public static HttpClient GenerateHttp(string cookie)
{ {
var handler = new HttpClientHandler(); var handler = new HttpClientHandler
handler.AllowAutoRedirect = false; {
handler.UseCookies = true; AllowAutoRedirect = false,
handler.CookieContainer = CreateCookie(cookie); UseCookies = true,
handler.AutomaticDecompression = DecompressionMethods.GZip; CookieContainer = CreateCookie(cookie),
handler.ClientCertificateOptions = ClientCertificateOption.Automatic; AutomaticDecompression = DecompressionMethods.GZip,
ClientCertificateOptions = ClientCertificateOption.Automatic
};
var http = new HttpClient(handler); var http = new HttpClient(handler);
GenerateHttpHeader(ref http); GenerateHttpHeader(ref http);
return http; return http;
} }
/// <summary>
/// 拼接Header参数
/// </summary>
/// <param name="http"></param>
private static void GenerateHttpHeader(ref HttpClient http) private static void GenerateHttpHeader(ref HttpClient http)
{ {
http.DefaultRequestHeaders.Add("Accept", "application/json, text/plain, */*"); http.DefaultRequestHeaders.Add("Accept", "application/json, text/plain, */*");
......
// See https://aka.ms/new-console-template for more information // See https://aka.ms/new-console-template for more information
using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks;
using TicketSpider.Spiders;
using TicketSpider.Spiders.ClassInRule; using TicketSpider.Spiders.ClassInRule;
public class Program namespace EduSpider
{ {
static void Main(string[] args) public class Program
{ {
static void Main(string[] args)
{
ThreadPool.SetMaxThreads(255, 255); ThreadPool.SetMaxThreads(255, 255);
ThreadPool.SetMinThreads(255, 255); ThreadPool.SetMinThreads(255, 255);
new ClassInFlow().StartAsync(); new ClassInFlow().StartAsync();
Console.ReadLine(); Console.ReadLine();
Environment.Exit(0); Environment.Exit(0);
}
} }
} }
\ No newline at end of file
...@@ -32,7 +32,7 @@ namespace EduSpider.Spiders.ClassInRule ...@@ -32,7 +32,7 @@ namespace EduSpider.Spiders.ClassInRule
var response = await request.PostAsync("https://console.eeo.cn/saasajax/course.ajax.php?action=getCourseList", content); var response = await request.PostAsync("https://console.eeo.cn/saasajax/course.ajax.php?action=getCourseList", content);
var result = response.Content.ReadAsStringAsync().Result; var result = response.Content.ReadAsStringAsync().Result;
List<RB_Course> list = new List<RB_Course>(); List<RB_Course> list = new();
if (!string.IsNullOrWhiteSpace(result)) if (!string.IsNullOrWhiteSpace(result))
{ {
JObject rootObj = JObject.Parse(result); JObject rootObj = JObject.Parse(result);
......
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