Job.Common/MyHttpClient.cs
(开头部分) 7KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using HtmlAgilityPack;
using Job.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
namespace Job.Common
{
public class MyHttpClient
{
#region HtmlWeb
public static HtmlWeb htmlWeb
{
get
{
if (HttpContext.Current.Session != null)
{
if (HttpContext.Current.Session["HtmlWeb"] == null)
HttpContext.Current.Session["HtmlWeb"] = new HtmlWeb();
return HttpContext.Current.Session["HtmlWeb"] as HtmlWeb;
}
return null;
}
}
#endregion
/// <summary>
/// 获取get请求返回的数据
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
public void GetRequest(ref List<ZhaopinInfo> zpInfoList, string url, ZhaopinType type)
{
//List<ZhaopinInfo> zpInfoList = new List<ZhaopinInfo>();
switch (type)
{
case ZhaopinType.猎聘网:
htmlWeb.OverrideEncoding = Encoding.GetEncoding("UTF-8");
HtmlAgilityPack.HtmlDocument response = htmlWeb.Load(url);
#region MyRegion
var ulS = response.DocumentNode.SelectNodes("//*[@id='sojob']/div[2]/div/div/ul/li");
foreach (var item in ulS)
{
var xpath = item.XPath;
string titleName, infourl, company, city, date, salary, salary_em, source;
titleName = item.SelectSingleNode(xpath + "/a").Attributes["title"].Value;
infourl = item.SelectSingleNode(xpath + "/a").Attributes["href"].Value;
company = item.SelectSingleNode(xpath + "/a/dl/dt[@class='company']").InnerText;
city = item.SelectSingleNode(xpath + "/a/dl/dt[@class='city']/span").InnerText;
date = item.SelectSingleNode(xpath + "/a/dl/dt[@class='date']/span").InnerText;
salary = item.SelectSingleNode(xpath + "/a/dl/dt[@class='salary']/span").InnerText;
salary_em = item.SelectSingleNode(xpath + "/a/dl/dt[@class='salary']/em").InnerText;
source = "猎聘网";
zpInfoList.Add(
new ZhaopinInfo()
后面还有 90 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。