-
Notifications
You must be signed in to change notification settings - Fork 0
/
Site.Master.cs
92 lines (71 loc) · 3.17 KB
/
Site.Master.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HtmlAgilityPack;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
namespace WebApplication23
{
public partial class SiteMaster : MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
HtmlAgilityPack.HtmlWeb web = new HtmlAgilityPack.HtmlWeb();
HtmlAgilityPack.HtmlDocument doc = web.Load(TextBox1.Text);
var Articles = doc.DocumentNode.SelectNodes("//*[@class ='article-single']");
foreach (var article in Articles)
{
var header = HttpUtility.HtmlDecode(article.SelectSingleNode(".//li[@class='article-header']" + "\n").InnerText);
var description = HttpUtility.HtmlDecode(article.SelectSingleNode(".//li[@class='article-copy']").InnerText);
Response.Write("<Table>");
Response.Write("<td>");
Response.Write("Name - " + header);
Response.Write("<br />");
Response.Write(" Description - " + description);
Response.Write("<tr />");
Response.Write("<td />");
Response.Write("</Table>");
}
}
catch (Exception ex) { Response.Write(ex.Message); }
}
protected void Button2_Click(object sender, EventArgs e)
{
HtmlAgilityPack.HtmlWeb web = new HtmlAgilityPack.HtmlWeb();
HtmlAgilityPack.HtmlDocument doc = web.Load(TextBox1.Text);
var Articles = doc.DocumentNode.SelectNodes("//*[@class ='article-single']");
string excelName = "data";
Response.ClearContent();
//Response.AddHeader("content-disposition", "attachment;filename=" + excelName + ".xls");
//Response.AddHeader("Content-Type", "application/vnd.ms-excel");
Response.ContentType = "application/vnd.ms-excel";
Response.AppendHeader("content-disposition", "attachment; filename="+excelName+".xls");
//Header for table records
//
Response.Write("Header");
Response.Write("\t");
Response.Write("Description");
Response.Write("\t");
foreach (var article in Articles)
{
var header = HttpUtility.HtmlDecode(article.SelectSingleNode(".//li[@class='article-header']" + "\n").InnerText);
var description = HttpUtility.HtmlDecode(article.SelectSingleNode(".//li[@class='article-copy']").InnerText);
Response.Write(header);
Response.Write("\t");
Response.Write(description);
Response.Write("\t");
Response.Write("\n");
}
Response.End();
}
}
}