如何检查特定的html标签? [英] how do I place a check about a particular html tag?

查看:69
本文介绍了如何检查特定的html标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设此网站链接:

http://worldwide.espacenet.com/publicationDetails/biblio?DB=EPODOC&II=0&ND= 3& adjacent = true& locale = en_EP& FT = D& date = 19950620& CC = US& NR = 5425515A& KC = A



I需要从许多此类链接中获取数据。我几乎完成了编写代码但面临一个小问题。如果您打开网页,则有一些数据(专利号)对应于也发布为:标题。我需要复制这些专利号并将其粘贴到excel中。问题是,有时标题也发表为:不存在,在这种情况下,我需要将单元格保持空白。如何检查网页中是否存在同时发布为:?



代码:



Assume this web link:
http://worldwide.espacenet.com/publicationDetails/biblio?DB=EPODOC&II=0&ND=3&adjacent=true&locale=en_EP&FT=D&date=19950620&CC=US&NR=5425515A&KC=A

I need to fetch data from many such links. I have almost completed writing the code but facing a small problem. If you open the web page, there is some data (patent numbers) corresponding to "Also published as:" title. I need to copy those patent numbers and paste it in excel. The problem is, sometimes the title "Also published as:" does not exist and in that case I need to keep the cell blank. How do I place a check that whether the "Also published as:" exists in the web page or not?

The code:

num3 = ActiveSheet.UsedRange.Rows.Count
For num2 = 2 To num3
ie1.Visible = True
ie1.navigate Range("T" & num2).Value
Do
DoEvents
Loop Until ie1.readyState = READYSTATE_COMPLETE
Set doc1 = ie1.document
dd1 = Trim(doc1.getElementsByTagName("th")(8).innerText)
If InStr(dd1, "published") Then
sdd1 = Trim(doc1.getElementsByTagName("td")(9).innerText)
Range("B" & num2).Value = sdd1
Else
Range("B" & num2).Value = ""
End If
Next num2
ie1.Quit





列T包含要访问的Web链接第9个标记包含文本同时发布为: 第10个标签包含要提取的数据(专利号)



请帮助



Column T contains the web links to be accessed 9th tag contains the text "Also published as:" 10th tag contains the data (patent numbers) to be fetched

Please help

推荐答案

这篇关于如何检查特定的html标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆