以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]web内容提取  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=133626)

--  作者:benwong2013
--  发布时间:2019/4/17 12:25:00
--  [求助]web内容提取
若要提取web html的文档如何提取标识红色字体内容

<html><body><table cellpadding="0" cellspacing="0" align="center" bgcolor="#ffffff" width="734" style="line-height:20px"><tbody><tr><td width="154" height="66"><img width="110" height="45" alt="前程无忧logo" src="http://img01.51jobcdn.com/im/2016/logo.png"></td><td><table cellspacing="0" cellpadding="0" border="0" bgcolor="#ffffff"><tbody><tr><td valign="top"><table cellspacing="0" cellpadding="0" border="0" width="440" bgcolor="#ffffff" style="font-size:12px;padding-right:8px"><tbody><tr><td valign="top" style="width:70px;color:#666666">应聘职位:</td><td valign="top" style="font-weight:bold;color:#333333;word-break:break-all">人力资源总监(东莞)</td></tr></tbody></table></td><td valign="top"><table cellspacing="0" cellpadding="0" border="0" width="140" bgcolor="#ffffff" style="font-size:12px"><tbody><tr><td valign="top" style="width:66px;color:#666666">投递时间:</td><td valign="top" style="font-weight:bold;color:#333333;word-break:break-all">2019-04-16</td></tr></tbody></table></td></tr><tr><td valign="top"><table cellspacing="0" cellpadding="0" border="0" width="440" bgcolor="#ffffff" style="font-size:12px;padding-right:8px"><tbody><tr><td valign="top" style="width:70px;color:#666666">应聘公司:</td><td valign="top" style="font-weight:bold;color:#333333;word-break:break-all">AA公司</td></tr></tbody></table></td><td valign="top"><table cellspacing="0" cellpadding="0" border="0" width="140" bgcolor="#ffffff" style="font-size:12px"><tbody><tr><td valign="top" style="width:66px;color:#666666">简历匹配:</td><td valign="top" style="font-weight:bold;color:#ff6000">65%</td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" c></meta><meta c name="format-detection"></meta></head><body><table cellpadding="0" cellspacing="0" align="center" bgcolor="#ffffff" width="734" style="line-height:20px;border:1px solid #dedede"><tbody><tr><td valign="top"><table xmlns="" cellspacing="0" cellpadding="0" border="0" bgcolor="#ffffff"><tbody><tr>
<td width="125" height="130" align="middle"><img src="c24bb7345b500fcc5548fd74b1ac719c_0_89624.jpg" width="85" height="104" style="display:block;background-color:#fafafa;border:0 none" alt="头像"></td>
<td>
<table cellspacing="0" cellpadding="0" border="0" width="592" style="font-size:12px;color:#333333;table-layout:auto"><tbody><tr>
<td width="400" style="padding-bottom:18px">
<strong style="font-size:18px;font-weight:normal">罗三贵</strong>&nbsp;|&nbsp;男&nbsp;|&nbsp;49 岁(1969/11/1)&nbsp;|&nbsp;20年工作经验
                  </td>
<td align="right" width="100" style="color:#a1a3ae;padding-bottom:18px;padding-right:5px">
                    ID:29229060</td>
</tr></tbody></table>
<table cellspacing="0" cellpadding="0" border="0" width="592" style="color:#333333;table-layout:auto"><tbody>
<tr>
<td valign="top" width="200" style="padding-right:10px"><table cellspacing="0" cellpadding="0" border="0" style="font-size:12px"><tbody><tr>
<td valign="top" width="85" style="line-height:20px;color:#666666">
                              手机:
                            </td>
<td valign="bottom" style="line-height:20px;color:#333333;word-break:break-all">13923111198</td>
</tr></tbody></table></td>
<td valign="top" width="331" style="padding-right:10px;padding-left:10px"><table cellspacing="0" cellpadding="0" border="0" style="font-size:12px"><tbody><tr>
<td valign="top" width="85" style="line-height:20px;color:#666666">
                              邮箱:
                            </td>
<td valign="bottom" style="line-height:20px;color:#333333;word-break:break-all"><a href="mailto:luoshanjin@126.com">luo111in@126.com</a></td>
</tr></tbody></table></td>
</tr>
<tr>
<td valign="top" width="200" style="padding-right:10px"><table cellspacing="0" cellpadding="0" border="0" style="font-size:12px"><tbody><tr>
<td valign="top" width="85" style="line-height:20px;color:#666666">
                              居住地:
                            </td>
<td valign="bottom" style="line-height:20px;color:#333333;word-break:bre

--  作者:有点色
--  发布时间:2019/4/17 12:43:00
--  

 

把你的网页另存一下,打包发上来测试。

 

 


--  作者:benwong2013
--  发布时间:2019/4/18 10:44:00
--  

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:resume.rar

最近用chrom和火狐浏览器都不能点击添加附件,最后用IE可以;

 

附件是另存的文档,请帮忙分析一下,谢谢!


--  作者:有点甜
--  发布时间:2019/4/18 11:48:00
--  

参考代码

 

Dim web As new System.Windows.Forms.WebBrowser
web.navigate("C:\\Users\\dv rrxaI600 007\\Downloads\\resume\\resume.html")
Do Until web.ReadyState = 4
    Application.DoEvents
Loop

Dim tbs As object = web.Document.GetElementsByTagName("table")
\'For i As Integer = 0 To tbs.count-1
    \'If tbs(i).Innerhtml.contains("luo111in@126.com")
        \'output.show(i)
        \'output.show(tbs(i).InnerHTML)
        \'output.show("-------------")
    \'End If
\'Next

Dim str = tbs(8).GetElementsByTagName("tr")(0).GetElementsByTagName("strong")(0)
msgbox(str.Innertext)
str = tbs(10).GetElementsByTagName("tr")(0).GetElementsByTagName("td")(1)
msgbox(str.Innertext)
str = tbs(11).GetElementsByTagName("tr")(0).GetElementsByTagName("td")(1)
msgbox(str.Innertext)

[此贴子已经被作者于2019/4/18 12:16:42编辑过]

--  作者:benwong2013
--  发布时间:2019/4/18 11:57:00
--  
一般抓取的时候可能tbs(i).Innerhtml.contains("luo111in@126.com") 是一个动态的,请问这个要如何修改;
--  作者:有点甜
--  发布时间:2019/4/18 12:17:00
--  

红色这段代码是用来测试的,可以删除

 

Dim web As new System.Windows.Forms.WebBrowser
web.navigate("C:\\Users\\dv rrxaI600 007\\Downloads\\resume\\resume.html")
Do Until web.ReadyState = 4
    Application.DoEvents
Loop

Dim tbs As object = web.Document.GetElementsByTagName("table")
\'For i As Integer = 0 To tbs.count-1
    \'If tbs(i).Innerhtml.contains("luo111in@126.com")
        \'output.show(i)
        \'output.show(tbs(i).InnerHTML)
        \'output.show("-------------")
    \'End If
\'Next

Dim str = tbs(8).GetElementsByTagName("tr")(0).GetElementsByTagName("strong")(0)
msgbox(str.Innertext)
str = tbs(10).GetElementsByTagName("tr")(0).GetElementsByTagName("td")(1)
msgbox(str.Innertext)
str = tbs(11).GetElementsByTagName("tr")(0).GetElementsByTagName("td")(1)
msgbox(str.Innertext)