You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.9 KiB
60 lines
1.9 KiB
using System.Net.Http; |
|
using System.Net.Http.Headers; |
|
using System.Threading.Tasks; |
|
using System.Net; |
|
using System.Text; |
|
using System.IO; |
|
using System; |
|
using HtmlAgilityPack; |
|
|
|
|
|
public class Address |
|
{ |
|
public string Street { get; set; } |
|
public string City { get; set; } |
|
public string State { get; set; } |
|
public string ZipCode { get; set; } |
|
} |
|
|
|
public class Posting |
|
{ |
|
public string Agency { get; set; } |
|
public string Title { get; set; } |
|
public string OccupationalCategory { get; set; } |
|
public string SalaryGrade { get; set; } |
|
public string BargainingUnit { get; set; } |
|
public string SalaryRange { get; set; } |
|
public string EmploymentType { get; set; } |
|
public string AppointmentType { get; set; } |
|
public string JurisdictionalClass { get; set; } |
|
public string TravelPercentage { get; set; } |
|
public string MinimumQualifications { get; set; } |
|
public string DutiesDescription { get; set; } |
|
public string ContactName { get; set; } |
|
public string ContactEmailAddress { get; set; } |
|
public Address LocationAddress { get; set; } |
|
public Address ContactAddress { get; set; } |
|
public string NotesOnApplying { get; set; } |
|
public string VacancyID { get; set; } |
|
public DateTime DatePosted { get; set; } |
|
public DateTime DateDue { get; set; } |
|
|
|
public Posting(string id) |
|
{ |
|
string fullUrl = $"https://statejobs.ny.gov/employees/vacancyDetailsView.cfm?id={id}"; |
|
using (var client = new HttpClient()) |
|
{ |
|
var response = client.GetAsync(fullUrl).Result; |
|
|
|
if (response.IsSuccessStatusCode) |
|
{ |
|
var responseContent = response.Content; |
|
|
|
// by calling .Result you are synchronously reading the result |
|
string responseString = responseContent.ReadAsStringAsync().Result; |
|
HtmlDocument htmlDoc = new HtmlDocument(); |
|
htmlDoc.LoadHtml(responseString); |
|
} |
|
} |
|
} |
|
} |