This commit is contained in:
13
Form1.Designer.cs
generated
13
Form1.Designer.cs
generated
@@ -37,6 +37,7 @@
|
|||||||
this.lbRespCnt = new System.Windows.Forms.Label();
|
this.lbRespCnt = new System.Windows.Forms.Label();
|
||||||
this.lbStatus = new System.Windows.Forms.Label();
|
this.lbStatus = new System.Windows.Forms.Label();
|
||||||
this.btOpen = new System.Windows.Forms.Button();
|
this.btOpen = new System.Windows.Forms.Button();
|
||||||
|
this.button1 = new System.Windows.Forms.Button();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// Process
|
// Process
|
||||||
@@ -102,11 +103,22 @@
|
|||||||
this.btOpen.UseVisualStyleBackColor = true;
|
this.btOpen.UseVisualStyleBackColor = true;
|
||||||
this.btOpen.Click += new System.EventHandler(this.btOpen_Click);
|
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
|
// Form1
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(367, 212);
|
this.ClientSize = new System.Drawing.Size(367, 212);
|
||||||
|
this.Controls.Add(this.button1);
|
||||||
this.Controls.Add(this.btOpen);
|
this.Controls.Add(this.btOpen);
|
||||||
this.Controls.Add(this.lbStatus);
|
this.Controls.Add(this.lbStatus);
|
||||||
this.Controls.Add(this.lbRespCnt);
|
this.Controls.Add(this.lbRespCnt);
|
||||||
@@ -134,6 +146,7 @@
|
|||||||
private System.Windows.Forms.Label lbRespCnt;
|
private System.Windows.Forms.Label lbRespCnt;
|
||||||
private System.Windows.Forms.Label lbStatus;
|
private System.Windows.Forms.Label lbStatus;
|
||||||
private System.Windows.Forms.Button btOpen;
|
private System.Windows.Forms.Button btOpen;
|
||||||
|
private System.Windows.Forms.Button button1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
49
Form1.cs
49
Form1.cs
@@ -8,6 +8,7 @@ using System.Text;
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
namespace WebChecker
|
namespace WebChecker
|
||||||
{
|
{
|
||||||
@@ -27,6 +28,8 @@ namespace WebChecker
|
|||||||
|
|
||||||
StreamWriter m_FileLog = new StreamWriter("WebChecker.log", true);
|
StreamWriter m_FileLog = new StreamWriter("WebChecker.log", true);
|
||||||
|
|
||||||
|
WebClient client = new WebClient();
|
||||||
|
|
||||||
public Form1()
|
public Form1()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -41,6 +44,9 @@ namespace WebChecker
|
|||||||
wb.ScriptErrorsSuppressed = true;
|
wb.ScriptErrorsSuppressed = true;
|
||||||
wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
|
wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
|
||||||
|
|
||||||
|
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
|
||||||
|
client.DownloadDataCompleted +=new DownloadDataCompletedEventHandler(client_DownloadDataCompleted);
|
||||||
|
|
||||||
Log("=== App Launch ===");
|
Log("=== App Launch ===");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,6 +99,8 @@ namespace WebChecker
|
|||||||
HtmlDocument doc = wb.Document;
|
HtmlDocument doc = wb.Document;
|
||||||
|
|
||||||
HtmlElement element = doc.GetElementById("sbPersonalInfo");
|
HtmlElement element = doc.GetElementById("sbPersonalInfo");
|
||||||
|
if(element == null)
|
||||||
|
return;
|
||||||
element = element.Children[element.Children.Count-1];
|
element = element.Children[element.Children.Count-1];
|
||||||
element = element.Children[0];
|
element = element.Children[0];
|
||||||
element = element.GetElementsByTagName("IMG")[0];
|
element = element.GetElementsByTagName("IMG")[0];
|
||||||
@@ -198,5 +206,46 @@ namespace WebChecker
|
|||||||
MessageBox.Show(other.Message);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,10 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="HtmlAgilityPack, Version=1.4.6.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>.\HtmlAgilityPack.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core">
|
<Reference Include="System.Core">
|
||||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
|
|||||||
Reference in New Issue
Block a user