diff --git a/Form1.Designer.cs b/Form1.Designer.cs
index 6b638a8..2598dcd 100644
--- a/Form1.Designer.cs
+++ b/Form1.Designer.cs
@@ -37,6 +37,7 @@
this.lbRespCnt = new System.Windows.Forms.Label();
this.lbStatus = new System.Windows.Forms.Label();
this.btOpen = new System.Windows.Forms.Button();
+ this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// Process
@@ -102,11 +103,22 @@
this.btOpen.UseVisualStyleBackColor = true;
this.btOpen.Click += new System.EventHandler(this.btOpen_Click);
//
+ // button1
+ //
+ this.button1.Location = new System.Drawing.Point(208, 128);
+ this.button1.Name = "button1";
+ this.button1.Size = new System.Drawing.Size(75, 23);
+ this.button1.TabIndex = 6;
+ this.button1.Text = "button1";
+ this.button1.UseVisualStyleBackColor = true;
+ this.button1.Click += new System.EventHandler(this.button1_Click);
+ //
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(367, 212);
+ this.Controls.Add(this.button1);
this.Controls.Add(this.btOpen);
this.Controls.Add(this.lbStatus);
this.Controls.Add(this.lbRespCnt);
@@ -134,6 +146,7 @@
private System.Windows.Forms.Label lbRespCnt;
private System.Windows.Forms.Label lbStatus;
private System.Windows.Forms.Button btOpen;
+ private System.Windows.Forms.Button button1;
}
}
diff --git a/Form1.cs b/Form1.cs
index bcb7929..c1a73b9 100644
--- a/Form1.cs
+++ b/Form1.cs
@@ -8,6 +8,7 @@ using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;
+using System.Net;
namespace WebChecker
{
@@ -27,6 +28,8 @@ namespace WebChecker
StreamWriter m_FileLog = new StreamWriter("WebChecker.log", true);
+ WebClient client = new WebClient();
+
public Form1()
{
InitializeComponent();
@@ -41,6 +44,9 @@ namespace WebChecker
wb.ScriptErrorsSuppressed = true;
wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
+ client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
+ client.DownloadDataCompleted +=new DownloadDataCompletedEventHandler(client_DownloadDataCompleted);
+
Log("=== App Launch ===");
}
@@ -93,6 +99,8 @@ namespace WebChecker
HtmlDocument doc = wb.Document;
HtmlElement element = doc.GetElementById("sbPersonalInfo");
+ if(element == null)
+ return;
element = element.Children[element.Children.Count-1];
element = element.Children[0];
element = element.GetElementsByTagName("IMG")[0];
@@ -198,5 +206,46 @@ namespace WebChecker
MessageBox.Show(other.Message);
}
}
+
+ private void button1_Click(object sender, EventArgs e)
+ {
+ //url = "http://main.com";
+ url = tbURL.Text;
+ client.DownloadDataAsync(new Uri(url));
+ }
+
+ void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
+ {
+
+ }
+
+ void client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
+ {
+ string conType = client.ResponseHeaders["Content-Type"];
+ int iPos = conType.IndexOf("charset");
+ Encoding enc = Encoding.Default;
+ if(iPos >= 0)
+ {
+ iPos = conType.IndexOf("=", iPos+"charset".Length);
+ if(iPos >= 0)
+ {
+ string charset = conType.Substring(iPos+1);
+ enc = Encoding.GetEncoding(charset);
+ }
+ }
+
+ string contents = enc.GetString(e.Result);
+
+ HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
+ doc.LoadHtml(contents);
+
+
+ HtmlAgilityPack.HtmlNode node = doc.DocumentNode.SelectSingleNode("//ul[@class='info']/li/img");
+ HtmlAgilityPack.HtmlAttribute attr = node.Attributes["src"];
+
+ string strInnerText = "";
+ if(attr != null)
+ strInnerText = attr.Value;
+ }
}
}
diff --git a/WebChecker.csproj b/WebChecker.csproj
index 8dd8f87..383f0ff 100644
--- a/WebChecker.csproj
+++ b/WebChecker.csproj
@@ -32,6 +32,10 @@
4
+
+ False
+ .\HtmlAgilityPack.dll
+
3.5