Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Net;
- using System.IO;
- using HtmlAgilityPack;
- namespace ROD_Deck_Builder
- {
- public class Pagedata
- {
- HtmlAgilityPack.HtmlDocument pageData;
- public HtmlAgilityPack.HtmlDocument PageData
- {
- get { return pageData; }
- set { pageData = value; }
- }
- public Pagedata()
- {
- }
- }
- public class GetPage
- {
- public static Pagedata GetPageData(string url)
- {
- WebRequest request = WebRequest.Create(url);
- WebResponse response = request.GetResponse();
- Stream data = response.GetResponseStream();
- HtmlDocument mydoc = new HtmlDocument();
- mydoc.OptionFixNestedTags = true;
- mydoc.Load(data);
- if (mydoc.ParseErrors != null && mydoc.ParseErrors.Count() > 0)
- {
- // Handle any parse errors as required
- }
- else
- {
- if (mydoc.DocumentNode != null)
- {
- HtmlAgilityPack.HtmlNode bodyNode = mydoc.DocumentNode.SelectSingleNode("//body");
- if (bodyNode != null)
- {
- // Do something with bodyNode
- mydoc.DocumentNode.SelectSingleNode("//table[@class='witiable sortable']");
- }
- return mydoc;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment