我想从一个网址中提取一个美国专利
(更新:正如评论所指出的那样,专利标题没有标注为“标题”;但是,它在网页上一直显示在“摘要”之上.)在大多数情况下,它在“身体”的第7个子元素中或文件中的第3个“字体”元素,但偶尔会在页面顶部发出“**请参见图像:(校正证书)**”或“(复审证书)”的两种方法在你到达标题之前,通过插入一个额外的“body”子项和三个额外的“font”元素来提取.
但是,标题似乎始终是第一个“font”元素,属性“size”的值为“1”.不幸的是,其他元素的大小=“ – 1”,包括并不总是存在的上述元素,因此必须具体使用该属性和值.我已经搜索但无法弄清楚如何按属性和值获取元素.这是我的代码:
Function Test_UpdateTitle(url As String)
Dim title As String
Dim pageSource As String
Dim xml_obj As XMLHTTP60
Set xml_obj = CreateObject("MSXML2.XMLHTTP")
xml_obj.Open "GET", url, False
xml_obj.send
pageSource = xml_obj.responseText
Set xml_obj = Nothing
Dim html_doc As HTMLdocument
Set html_doc = CreateObject("HTMLFile")
html_doc.body.innerHTML = pageSource
Dim fontElement As IHTMLElement
'Methods 1 and 2 fail in cases of a certificate of correction or reexamination certificate
'Method 1
' Dim body As IHTMLElement
' Set body = html_doc.getElementsByTagName("body").Item(0)
' Set fontElement = body.Children(6)
'Method 2
' Set fontElement = html_doc.getElementsByTagName("font").Item(3)
'Method 3
Dim n As Integer
For n = 3 To html_doc.getElementsByTagName("font").Length - 1
Set fontElement = html_doc.getElementsByTagName("font").Item(n)
If InStr(fontElement.innerText, "Please see") = 0 And _
InStr(fontElement.innerText, "( Certificate of Correction )") = 0 And _
InStr(fontElement.innerText, "( Reexamination Certificate )") = 0 And _
InStr(fontElement.innerText, " **") = 0 Then
Test_UpdateTitle = fontElement.innerText
Exit Function
End If
Next n
End Function