數(shù)據(jù)采集算法與實(shí)現(xiàn)(doc 6頁(yè)).doc_第1頁(yè)
數(shù)據(jù)采集算法與實(shí)現(xiàn)(doc 6頁(yè)).doc_第2頁(yè)
數(shù)據(jù)采集算法與實(shí)現(xiàn)(doc 6頁(yè)).doc_第3頁(yè)
數(shù)據(jù)采集算法與實(shí)現(xiàn)(doc 6頁(yè)).doc_第4頁(yè)
數(shù)據(jù)采集算法與實(shí)現(xiàn)(doc 6頁(yè)).doc_第5頁(yè)
已閱讀5頁(yè),還剩1頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

數(shù)據(jù)采集算法以及實(shí)現(xiàn)/先按照下面的字段創(chuàng)建一個(gè)數(shù)據(jù)表以下為引用的內(nèi)容:public partial class Form2 : Form public Form2() InitializeComponent(); /姓名 public static string XM = ; /年齡 public static string nl = ; /性別 public static string XB = ; /身高 public static string SG = ; /政治面貌 public static string mm = ; /民族 public static string MZ = ; /學(xué)歷 public static string XL = ; /婚姻狀況 public static string HK = ; /所學(xué)專業(yè) public static string ZY = ; /工作經(jīng)驗(yàn) public static string GZJY = ; /在職單位 public static string ZZDW = ; /在職職位 public static string ZZZW = ; /工作經(jīng)歷 public static string GZJL = ; /要求月薪 public static string YX = ; /工作性質(zhì) public static string GZXZ = ; /求職意向 public static string QZYX = ; /具體職務(wù) public static string JTZW = ; /期望工作地 public static string QWGZD = ; /教育情況,語(yǔ)言水平,技術(shù)專長(zhǎng) public static string QT = ; private void button1_Click(object sender, EventArgs e) label1.Text = 正在采集數(shù)據(jù); /遍歷數(shù)據(jù)的頁(yè)數(shù) for (int i = 1; i =50; i+) CJ(/renli.asp?pageno= + i); label1.Text = 恭喜你采集完成!; MessageBox.Show(恭喜你采集完成!); /采集數(shù)據(jù) private void CJ(string Url) /獲得頁(yè)面源文件(Html) string strWebContent = YM(Url); /按照tml里面的標(biāo)簽 取出和數(shù)據(jù)有關(guān)的那段源碼 int iBodyStart = strWebContent.IndexOf(body, 0); int aaa = strWebContent.IndexOf(關(guān)鍵字:, iBodyStart); int iTableStart = strWebContent.IndexOf(table, aaa); int iTableEnd = strWebContent.IndexOf(, iTableStart); string strWeb = strWebContent.Substring(iTableStart, iTableEnd - iTableStart); /生成HtmlDocument HtmlElementCollection htmlTR = HtmlTR_Content(strWeb, tr); foreach (HtmlElement tr in htmlTR) try /姓名 XM = tr.GetElementsByTagName(a)0.InnerText; /獲得詳細(xì)信息頁(yè)面的網(wǎng)址 string a = tr.GetElementsByTagName(a)0.GetAttribute(href).ToString(); a = + a.Substring(11); Content(a); catch /采集詳細(xì)數(shù)據(jù) private void Content(string URL) try string strWebContent = YM(URL); /按照tml里面的標(biāo)簽 取出和數(shù)據(jù)有關(guān)的那段源碼 int iBodyStart = strWebContent.IndexOf(body, 0); int iTableStart = strWebContent.IndexOf(瀏覽次數(shù), iBodyStart); int iTableEnd = strWebContent.IndexOf(table, iTableStart); int dd = strWebContent.IndexOf(, iTableEnd); string strWeb = strWebContent.Substring(iTableEnd, dd - iTableEnd + 8); HtmlElementCollection htmlTR = HtmlTR_Content(strWeb, table); foreach (HtmlElement tr in htmlTR) try /年齡 nl = tr.GetElementsByTagName(tr)1.GetElementsByTagName(td)1.InnerText; /性別 string XB_SG = tr.GetElementsByTagName(tr)1.GetElementsByTagName(td)3.InnerText; XB = XB_SG.Substring(0, 1); /身高 SG = XB_SG.Substring(11); /政治面貌 mm = tr.GetElementsByTagName(tr)2.GetElementsByTagName(td)1.InnerText; /民族 MZ = tr.GetElementsByTagName(tr)2.GetElementsByTagName(td)3.InnerText; /學(xué)歷 XL = tr.GetElementsByTagName(tr)3.GetElementsByTagName(td)1.InnerText; /婚煙狀況 HK = tr.GetElementsByTagName(tr)3.GetElementsByTagName(td)3.InnerText; /所學(xué)專業(yè) ZY = tr.GetElementsByTagName(tr)5.GetElementsByTagName(td)1.InnerText; /工作經(jīng)驗(yàn) GZJY = tr.GetElementsByTagName(tr)5.GetElementsByTagName(td)3.InnerText; /在職單位 ZZDW = tr.GetElementsByTagName(tr)6.GetElementsByTagName(td)1.InnerText; /在職職位 ZZZW = tr.GetElementsByTagName(tr)6.GetElementsByTagName(td)3.InnerText; /工作經(jīng)歷 GZJY = tr.GetElementsByTagName(tr)7.GetElementsByTagName(td)1.InnerText; /要求月薪 YX = tr.GetElementsByTagName(tr)9.GetElementsByTagName(td)1.InnerText; /工作性質(zhì) GZXZ = tr.GetElementsByTagName(tr)9.GetElementsByTagName(td)3.InnerText; /求職意向 QZYX = tr.GetElementsByTagName(tr)10.GetElementsByTagName(td)1.InnerText; /具體職務(wù) JTZW = tr.GetElementsByTagName(tr)10.GetElementsByTagName(td)3.InnerText; /期望工作地 QWGZD = tr.GetElementsByTagName(tr)11.GetElementsByTagName(td)1.InnerText; /教育情況,語(yǔ)言水平,技術(shù)專長(zhǎng) QT = tr.GetElementsByTagName(tr)13.GetElementsByTagName(td)1.InnerText; insert(); catch catch /將數(shù)據(jù)插入數(shù)據(jù)庫(kù) private void insert() try string str = Provider=Microsoft.Jet.OleDb.4.0;Data Source=Data.mdb; string sql = insert into 人才信息 (姓名,年齡,性別,身高,政治面貌,民族,學(xué)歷,婚煙狀況,所學(xué)專業(yè),; sql += 工作經(jīng)驗(yàn),在職單位,在職職位,工作經(jīng)歷,要求月薪,工作性質(zhì),求職意向,具體職務(wù),期望工作地,其他) values ; sql += ( + XM + , + nl + , + XB + , + SG + , + mm + , + MZ + , + XL + , + HK + , + ZY + , + GZJY + , + ZZDW + , + ZZZW + ,; sql += + GZJY + , + YX + , + GZXZ + , + QZYX + , + JTZW + , + QWGZD + , + QT + ); OleDbConnection con = new OleDbConnection(str); OleDbCommand com = new OleDbCommand(sql, con); con.Open(); com.ExecuteNonQuery(); con.Close(); catch /返回一個(gè)HtmlElementCollection,然后進(jìn)行查詢內(nèi)容 private HtmlElementCollection HtmlTR_Content(string strWeb, string tj) try /生成HtmlDocument WebBrowser webb = new WebBrowser(); webb.Navigate(about:blank); /window.document返回一個(gè)htmldocument對(duì)象,表示對(duì)一個(gè)html文檔的操

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論