Create a gist now

Instantly share code, notes, and snippets.

anonymous /html parser
Created Apr 24, 2015

What would you like to do?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using HtmlAgilityPack;
namespace FinalProject2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
var getHtmlWeb = new HtmlWeb();
HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
htmlDoc.OptionFixNestedTags = true;
htmlDoc.Load("2012 Spring - On-Line Class Schedule Query Results.htm");
//var doc = htmlDoc.DocumentNode.SelectNodes("/html/body/div[3]/div[2]/table/tr[3]");
// var doc = htmlDoc.DocumentNode.SelectNodes("//tr");
var doc = htmlDoc.DocumentNode.SelectNodes("/html/body/div[3]/div[2]/table//tr");
// var doc = htmlDoc.DocumentNode.SelectNodes("//*[@class='ddhighlight']");
if (doc != null)
{
foreach (var docs in doc)
{
textBox1.Text += docs.InnerText ;
}
}
else
{
textBox1.Text = "Nothing was found";
}
}
}
}
<TABLE CLASS="datadisplaytable" SUMMARY="This table houses the Class Schedule Results" CAPTION="Class Schedule" width="100%">
<TR>
<TH NOWRAP CLASS="ddheader" scope="col" width="40"><p class="centeraligntext"><img border="0" src="/puc/spacer.gif" width="40" height="1" alt=""><br>CRN</p></TH>
<TH NOWRAP CLASS="ddheader" scope="col" width="40"><p class="centeraligntext"><img border="0" src="/puc/spacer.gif" width="40" height="1" alt=""><br>Subj.</p></TH>
<TH NOWRAP CLASS="ddheader" scope="col" width="57"><p class="centeraligntext"><img border="0" src="/puc/spacer.gif" width="57" height="1" alt=""><br>#</p></TH>
<TH NOWRAP CLASS="ddheader" scope="col" width="57"><p class="centeraligntext"><img border="0" src="/puc/spacer.gif" width="57" height="1" alt=""><br>Section</p></TH>
<TH NOWRAP CLASS="ddheader" scope="col" width="57"><p class="centeraligntext"><img border="0" src="/puc/spacer.gif" width="57" height="1" alt=""><br>Cr Hrs</p></TH>
<TH NOWRAP CLASS="ddheader" scope="col" width="80"><p class="centeraligntext"><img border="0" src="/puc/spacer.gif" width="80" height="1" alt=""><br>Enrollment<br>Taken/Avail</p></TH>
<TH NOWRAP CLASS="ddheader" scope="col" width="80"><p class="centeraligntext"><img border="0" src="/puc/spacer.gif" width="80" height="1" alt=""><br>Waitlist<br>Taken/Avail</p></TH>
<TH NOWRAP CLASS="ddheader" scope="col" width="160"><p class="centeraligntext"><img border="0" src="/puc/spacer.gif" width="160" height="1" alt=""><br>Title</p></TH>
<TH NOWRAP CLASS="ddheader" scope="col" width="100%"><p class="centeraligntext">Section Meeting Dates</p></TH>
</TR>
<TR>
<TD COLSPAN="2" CLASS="ddheader"><p class="centeraligntext">Type</p></TD>
<TD CLASS="ddheader"><p class="centeraligntext">Days</p></TD>
<TD COLSPAN="2" CLASS="ddheader"><p class="centeraligntext">Times</p></TD>
<TD COLSPAN="2" CLASS="ddheader"><p class="centeraligntext">Building - Room</p></TD>
<TD CLASS="ddheader"><p class="centeraligntext">Instructor</p></TD>
<TD CLASS="ddheader"><p class="centeraligntext">Important comments about the section.</p></TD>
</TR>
<TR>
<TD NOWRAP CLASS="ddhighlight">
<A HREF="javascript:openWindow('/pls/proddad/Webctlg.P_CtlgProcInput?inputsubjcode=AAE&inputsymbol==&inputcrsenumb=60700&inputcoursetype=2&inputreqind=2&callpage=clistquery')">66886</A>
<TD NOWRAP CLASS="ddhighlight">AAE</TD>
<TD NOWRAP CLASS="ddhighlight">60700</TD>
<TD NOWRAP CLASS="ddhighlight">01</TD>
<TD NOWRAP CLASS="ddhighlight">3.0</TD>
<TD NOWRAP CLASS="ddhighlight">
0 /
<SPAN class="fieldRedtext">0</SPAN>
</TD>
<TD NOWRAP CLASS="ddhighlight">
<SPAN class="fieldRedtext">N/A</SPAN>
</TD>
<TD CLASS="ddhighlight">Variational Prncpl of Mechanic</TD>
<TD CLASS="ddhighlight">JAN 17, 2012 to MAY 12, 2012</TD>
</TR>
<TR>
<TD COLSPAN="2" NOWRAP CLASS="dddefault">Distance Learning</TD>
<TD NOWRAP CLASS="dddefault">-</TD>
<TD COLSPAN="2" NOWRAP CLASS="dddefault">Distance Learning</TD>
<TD COLSPAN="2" CLASS="dddefault">
Distance Learning Courses
</TD>
<TD NOWRAP CLASS="dddefault">To Be Announced</TD>
<TD ROWSPAN="1" CLASS="dddefault"><A HREF="http://www.bkstr.com/webapp/wcs/stores/servlet/booklookServlet?bookstore_id-1=154&term_id-1=211122&div-1=&dept-1=AAE&course-1=60700&section-1=01" TARGET="_blank">View Books</A><br></TD>
</TR>
<TR>
<TD NOWRAP CLASS="ddhighlight">
<A HREF="javascript:openWindow('/pls/proddad/Webctlg.P_CtlgProcInput?inputsubjcode=AAE&inputsymbol==&inputcrsenumb=62600&inputcoursetype=2&inputreqind=2&callpage=clistquery')">66887</A>
<TD NOWRAP CLASS="ddhighlight">AAE</TD>
<TD NOWRAP CLASS="ddhighlight">62600</TD>
<TD NOWRAP CLASS="ddhighlight">01</TD>
<TD NOWRAP CLASS="ddhighlight">3.0</TD>
<TD NOWRAP CLASS="ddhighlight">
0 /
<SPAN class="fieldRedtext">0</SPAN>
</TD>
<TD NOWRAP CLASS="ddhighlight">
<SPAN class="fieldRedtext">N/A</SPAN>
</TD>
<TD CLASS="ddhighlight">Turbulence & Turbulence Model</TD>
<TD CLASS="ddhighlight">JAN 17, 2012 to MAY 12, 2012</TD>
</TR>
<TR>
<TD COLSPAN="2" NOWRAP CLASS="dddefault">Distance Learning</TD>
<TD NOWRAP CLASS="dddefault">-</TD>
<TD COLSPAN="2" NOWRAP CLASS="dddefault">Distance Learning</TD>
<TD COLSPAN="2" CLASS="dddefault">
Distance Learning Courses
</TD>
<TD NOWRAP CLASS="dddefault">To Be Announced</TD>
<TD ROWSPAN="1" CLASS="dddefault"><A HREF="http://www.bkstr.com/webapp/wcs/stores/servlet/booklookServlet?bookstore_id-1=154&term_id-1=211122&div-1=&dept-1=AAE&course-1=62600&section-1=01" TARGET="_blank">View Books</A><br></TD>
</TR>
<TR>
<TD NOWRAP CLASS="ddhighlight">
<A HREF="javascript:openWindow('/pls/proddad/Webctlg.P_CtlgProcInput?inputsubjcode=AD&inputsymbol==&inputcrsenumb=10500&inputcoursetype=2&inputreqind=2&callpage=clistquery')">66998</A>
<TD NOWRAP CLASS="ddhighlight">AD</TD>
<TD NOWRAP CLASS="ddhighlight">10500</TD>
<TD NOWRAP CLASS="ddhighlight">01</TD>
<TD NOWRAP CLASS="ddhighlight">3.0</TD>
<TD NOWRAP CLASS="ddhighlight">
19 /
<SPAN class="fieldGreentext">1</SPAN>
</TD>
<TD NOWRAP CLASS="ddhighlight">
<SPAN class="fieldRedtext">N/A</SPAN>
</TD>
<TD CLASS="ddhighlight">Design I</TD>
<TD CLASS="ddhighlight">JAN 17, 2012 to MAY 12, 2012</TD>
</TR>
<TR>
<TD COLSPAN="2" NOWRAP CLASS="dddefault">Studio</TD>
<TD NOWRAP CLASS="dddefault">TR</TD>
<TD COLSPAN="2" NOWRAP CLASS="dddefault">11:00 AM - 01:50 PM</TD>
<TD COLSPAN="2" CLASS="dddefault">
Gyte (Millard E) Science Bldg
- 036
</TD>
<TD NOWRAP CLASS="dddefault">Ashby, Nancy</TD>
<TD ROWSPAN="1" CLASS="dddefault"><A HREF="http://www.bkstr.com/webapp/wcs/stores/servlet/booklookServlet?bookstore_id-1=154&term_id-1=211122&div-1=&dept-1=AD&course-1=10500&section-1=01" TARGET="_blank">View Books</A><br></TD>
</TR>
<TR>
<TD NOWRAP CLASS="ddhighlight">
<A HREF="javascript:openWindow('/pls/proddad/Webctlg.P_CtlgProcInput?inputsubjcode=AD&inputsymbol==&inputcrsenumb=11300&inputcoursetype=2&inputreqind=2&callpage=clistquery')">63789</A>
<TD NOWRAP CLASS="ddhighlight">AD</TD>
<TD NOWRAP CLASS="ddhighlight">
<A HREF="http://www.transferin.net/" TARGET="_blank" nowrap>11300(TransferIN)</A>
<TD NOWRAP CLASS="ddhighlight">01</TD>
<TD NOWRAP CLASS="ddhighlight">3.0</TD>
<TD NOWRAP CLASS="ddhighlight">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment