Start of webscraping
This commit is contained in:
60
Posting.cs
Normal file
60
Posting.cs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -5,6 +5,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="HtmlAgilityPack" Version="1.11.34" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user