已阅读5页,还剩1页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
数据采集算法以及实现/先按照下面的字段创建一个数据表以下为引用的内容: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 = ; /学历 public static string XL = ; /婚姻状况 public static string HK = ; /所学专业 public static string ZY = ; /工作经验 public static string GZJY = ; /在职单位 public static string ZZDW = ; /在职职位 public static string ZZZW = ; /工作经历 public static string GZJL = ; /要求月薪 public static string YX = ; /工作性质 public static string GZXZ = ; /求职意向 public static string QZYX = ; /具体职务 public static string JTZW = ; /期望工作地 public static string QWGZD = ; /教育情况,语言水平,技术专长 public static string QT = ; private void button1_Click(object sender, EventArgs e) label1.Text = 正在采集数据; /遍历数据的页数 for (int i = 1; i =50; i+) CJ(/renli.asp?pageno= + i); label1.Text = 恭喜你采集完成!; MessageBox.Show(恭喜你采集完成!); /采集数据 private void CJ(string Url) /获得页面源文件(Html) string strWebContent = YM(Url); /按照tml里面的标签 取出和数据有关的那段源码 int iBodyStart = strWebContent.IndexOf(body, 0); int aaa = strWebContent.IndexOf(关键字:, 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; /获得详细信息页面的网址 string a = tr.GetElementsByTagName(a)0.GetAttribute(href).ToString(); a = + a.Substring(11); Content(a); catch /采集详细数据 private void Content(string URL) try string strWebContent = YM(URL); /按照tml里面的标签 取出和数据有关的那段源码 int iBodyStart = strWebContent.IndexOf(body, 0); int iTableStart = strWebContent.IndexOf(浏览次数, 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; /学历 XL = tr.GetElementsByTagName(tr)3.GetElementsByTagName(td)1.InnerText; /婚烟状况 HK = tr.GetElementsByTagName(tr)3.GetElementsByTagName(td)3.InnerText; /所学专业 ZY = tr.GetElementsByTagName(tr)5.GetElementsByTagName(td)1.InnerText; /工作经验 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; /工作经历 GZJY = tr.GetElementsByTagName(tr)7.GetElementsByTagName(td)1.InnerText; /要求月薪 YX = tr.GetElementsByTagName(tr)9.GetElementsByTagName(td)1.InnerText; /工作性质 GZXZ = tr.GetElementsByTagName(tr)9.GetElementsByTagName(td)3.InnerText; /求职意向 QZYX = tr.GetElementsByTagName(tr)10.GetElementsByTagName(td)1.InnerText; /具体职务 JTZW = tr.GetElementsByTagName(tr)10.GetElementsByTagName(td)3.InnerText; /期望工作地 QWGZD = tr.GetElementsByTagName(tr)11.GetElementsByTagName(td)1.InnerText; /教育情况,语言水平,技术专长 QT = tr.GetElementsByTagName(tr)13.GetElementsByTagName(td)1.InnerText; insert(); catch catch /将数据插入数据库 private void insert() try string str = Provider=Microsoft.Jet.OleDb.4.0;Data Source=Data.mdb; string sql = insert into 人才信息 (姓名,年龄,性别,身高,政治面貌,民族,学历,婚烟状况,所学专业,; sql += 工作经验,在职单位,在职职位,工作经历,要求月薪,工作性质,求职意向,具体职务,期望工作地,其他) 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 /返回一个HtmlElementCollection,然后进行查询内容 private HtmlElementCollection HtmlTR_Content(string strWeb, string tj) try /生成HtmlDocument WebBrowser webb = new WebBrowser(); webb.Navigate(about:blank); /window.document返回一个htmldocument对象,表示对一个html文档的操
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 网络培训与企业文化建设-洞察及研究
- 量子算法优化的并行计算研究-洞察及研究
- 初中英语听说训练专项教案
- 海上航标维护合同范本
- 活体养殖寄养合同范本
- 大数据资产在金融科技中的应用前景
- 现场安全文明施工监理方案试卷教案(2025-2026学年)
- 建筑灌浆作业合同标准范本详解
- 高中数学(北师大版)必修四教案角的概念的推广参考教案(2025-2026学年)
- 山西省朔州市怀仁市2026届物理八年级第一学期期末预测试题含解析
- 道路货物运输企业安全生产责任制和事故报告制度
- 邮投递服务投标方案(技术标)
- 对外信息发布审批流程
- 医院护理培训课件:《肌肉注射法》
- 中医绝技临床实战特效绝活
- 路德维希·费尔巴哈和德国古典哲学的终结剖析课件
- 中医体质学说
- 现代汉语课件完全版
- GB/T 1927.4-2021无疵小试样木材物理力学性质试验方法第4部分:含水率测定
- GB/T 13663-2000给水用聚乙烯(PE)管材
- 唐诗三百首全集注音版
评论
0/150
提交评论