資源簡介
自動登錄qq空間,獲取最近訪客列表.
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { Timer terAutologin = new Timer(); public Form1() { InitializeComponent(); terAutologin.Enabled = true; terAutologin.Interval = 3 * 1000; terAutologin.Tick = ter_Tick; } void ter_Tick(object sender, EventArgs e) { if(wb1.Document==null) { return; } HtmlElement dialog_content_1 = wb1.Document.GetElementById("dialog_content_1"); if (dialog_content_1 == null) { return; } var frame = wb1.Document.Window.Frames[0]; if (frame==null) { return; } if (frame.Document==null) { return; } // iframe HtmlElement u = frame.Document.GetElementById("u"); u.InnerText = "171586098"; HtmlElement p = frame.Document.GetElementById("p"); p.InnerText = "*************"; p.SetAttribute("value", "********"); HtmlElement login_button = frame.Document.GetElementById("login_button"); login_button.InvokeMember("click"); terAutologin.Stop(); } private void Form1_Load(object sender, EventArgs e) { ssl1.Text = string.Empty; txtUrl.Text = "http://user.qzone.qq.com/14371939"; wb1.ScriptErrorsSuppressed = true; wb1.Navigate("http://user.qzone.qq.com/14371939/main"); } private void btnGO_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtUrl.Text)) { wb1.Navigate(txtUrl.Text); ssl1.Text = txtUrl.Text " Navigated"; } } private void wb1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { System.Diagnostics.Trace.WriteLine(e.Url.ToString()); // http://g.cnc.qzone.qq.com/cgi-bin/friendshow/cgi_get_visitor_simple?uin=4371939&type=1&mask=3&rd=0.7801240284461528&_=1397644130601&g_tk=9281770 ssl1.Text = e.Url.ToString() " Completed"; tryRead(); } private void btnTest_Click(object sender, EventArgs e) { tryRead(); } private void tryRead() { if (wb1.Document == null) { return; } HtmlElement pagediv = wb1.Document.GetElementById("visitor_list_page_con"); if (pagediv==null) { return; } //若分頁內容存在,則表示已經加載過了. if(pagediv.Children.Count>0) { handlerAbc(null,null); return; } //模擬點擊 "最近訪客" var aa = pagediv.Parent.Parent.FirstChild.Children[2]; aa.InvokeMember("click"); //給訪問列表的容器綁定一個事件...回調時就能獲取到. HtmlElement guestlist = pagediv.Parent.FirstChild; //ul.RaiseEvent guestlist.AttachEventHandler("onpropertychange", new EventHandler(handlerAbc)); } private void handlerAbc(Object sender, EventArgs e) { HtmlElement div = wb1.Document.GetElementById("visitor_list_page_con"); HtmlElement guestlist = div.Parent.FirstChild; if (guestlist.InnerHtml.IndexOf("QZONE.FrontPage.showLoginBox") > -1) { HtmlElement alogin = guestlist.GetElementsByTagName("a")[0]; alogin.InvokeMember("click"); // 使用定時器.檢測登錄窗口的出現.. terAutologin.Start(); return; } else { System.Text.StringBuilder sb = new StringBuilder(); // 取回里面的內容? foreach (HtmlElement li in guestlist.Children) { string qq = li.GetAttribute("uin"); string visitname = li.Children[1].FirstChild.InnerText; string visittime = li.Children[1].Children[1].InnerText; sb.AppendLine(qq visitname visittime); } MessageBox.Show(sb.ToString()); } } } }
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
namespace?WindowsFormsApplication1
{
????public?partial?class?Form1?:?Form
????{
????????Timer?terAutologin?=?new?Timer();
????????public?Form1()
????????{
????????????InitializeComponent();
????????????terAutologin.Enabled?=?true;
????????????terAutologin.Interval?=?3?*?1000;
????????????terAutologin.Tick?+=?ter_Tick;
????????}
????????void?ter_Tick(object?sender?EventArgs?e)
????????{
????????????if(wb1.Document==null)
????????????{
????????????????return;
????????????}
????????????HtmlElement?dialog_content_1?=?wb1.Document.GetElementById(“dialog_content_1“);
???????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????13824??2014-04-16?20:14??WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
?????文件??????28160??2014-04-16?20:14??WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb
?????文件??????24216??2014-04-16?20:15??WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe
?????文件????????490??2013-03-18?17:00??WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe.manifest
?????文件???????4906??2014-04-18?16:20??WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs
?????文件???????6277??2014-04-09?11:45??WindowsFormsApplication1\WindowsFormsApplication1\Form1.Designer.cs
?????文件???????6008??2014-04-09?11:45??WindowsFormsApplication1\WindowsFormsApplication1\Form1.resx
?????文件???????1453??2014-04-09?10:24??WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件???????6924??2014-04-08?17:02??WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件???????1050??2014-04-16?20:15??WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.FileListAbsolute.txt
?????文件????????977??2014-04-09?11:49??WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.GenerateResource.Cache
?????文件???????2211??2014-04-08?17:04??WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csprojResolveAssemblyReference.cache
?????文件??????13824??2014-04-16?20:14??WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.exe
?????文件????????180??2014-04-09?11:49??WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Form1.resources
?????文件??????28160??2014-04-16?20:14??WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.pdb
?????文件????????180??2014-04-08?17:04??WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Properties.Resources.resources
?????文件????????505??2014-04-08?17:02??WindowsFormsApplication1\WindowsFormsApplication1\Program.cs
?????文件???????1390??2014-04-08?17:02??WindowsFormsApplication1\WindowsFormsApplication1\Properties\AssemblyInfo.cs
?????文件???????2900??2014-04-08?17:02??WindowsFormsApplication1\WindowsFormsApplication1\Properties\Resources.Designer.cs
?????文件???????5612??2014-04-08?17:02??WindowsFormsApplication1\WindowsFormsApplication1\Properties\Resources.resx
?????文件???????1111??2014-04-08?17:02??WindowsFormsApplication1\WindowsFormsApplication1\Properties\Settings.Designer.cs
?????文件????????249??2014-04-08?17:02??WindowsFormsApplication1\WindowsFormsApplication1\Properties\Settings.settings
?????文件???????3762??2014-04-08?17:04??WindowsFormsApplication1\WindowsFormsApplication1\WindowsFormsApplication1.csproj
?????文件???????1041??2014-04-08?17:02??WindowsFormsApplication1\WindowsFormsApplication1.sln
????..A..H.?????43520??2014-04-16?21:16??WindowsFormsApplication1\WindowsFormsApplication1.v12.suo
?????目錄??????????0??2014-04-08?17:02??WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\TempPE
?????目錄??????????0??2014-04-08?17:04??WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug
?????目錄??????????0??2014-04-16?20:14??WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug
?????目錄??????????0??2014-04-08?17:02??WindowsFormsApplication1\WindowsFormsApplication1\bin
?????目錄??????????0??2014-04-08?17:02??WindowsFormsApplication1\WindowsFormsApplication1\obj
............此處省略6個文件信息
評論
共有 條評論