vba解析href [英] VBA parsing of href
问题描述
我有 googled ,并且还搜索了许多Stack的帖子,其中一些对于1 ,2 , 3 , 4
I've googled and also searched many posts on Stack some of them interesting for this1,2,3,4
我会告诉你我以后的事情。我选择了一个随机网站,并复制了几行(从155到174)
I'll show you what i am after. I picked a random site and copied a few lines (from 155 to 174)
<ul>
<li><a href="/wiki/B.A.C._I" title="B.A.C. I" class="mw-redirect">B.A.C. I</a></li>
<li><a href="/wiki/B.A.C._II" title="B.A.C. II" class="mw-redirect">B.A.C. II</a></li>
<li><a href="/wiki/B.A.C._III" title="B.A.C. III" class="mw-redirect">B.A.C. III</a></li>
<li><a href="/wiki/B.A.C._IV" title="B.A.C. IV" class="mw-redirect">B.A.C. IV</a></li>
<li><a href="/wiki/B.A.C._V" title="B.A.C. V" class="mw-redirect">B.A.C. V</a></li>
<li><a href="/wiki/B.A.C._VI" title="B.A.C. VI" class="mw-redirect">B.A.C. VI</a></li>
<li><a href="/wiki/B.A.C._VII" title="B.A.C. VII" class="mw-redirect">B.A.C. VII</a></li>
<li><a href="/wiki/B.A.C._VII_Mk.2" title="B.A.C. VII Mk.2" class="mw-redirect">B.A.C. VII Mk.2</a></li>
<li><a href="/wiki/B.A.C._VII_Planette" title="B.A.C. VII Planette" class="mw-redirect">B.A.C. VII Planette</a></li>
<li><a href="/wiki/B.A.C._VIII" title="B.A.C. VIII" class="mw-redirect">B.A.C. VIII</a></li>
<li><a href="/wiki/B.A.C._VIII_Bat-Boat" title="B.A.C. VIII Bat-Boat" class="mw-redirect">B.A.C. VIII Bat-Boat</a></li>
<li><a href="/wiki/B.A.C._IX" title="B.A.C. IX" class="mw-redirect">B.A.C. IX</a></li>
<li><a href="/wiki/B.A.C._Cupid" title="B.A.C. Cupid" class="mw-redirect">B.A.C. Cupid</a></li>
<li><a href="/wiki/B.A.C._Drone" title="B.A.C. Drone" class="mw-redirect">B.A.C. Drone</a></li>
<li><a href="/wiki/B.A.C._Super_Drone" title="B.A.C. Super Drone" class="mw-redirect">B.A.C. Super Drone</a></li>
<li><a href="/wiki/B.A._Swallow_2" title="B.A. Swallow 2" class="mw-redirect">B.A. Swallow 2</a></li>
<li><a href="/wiki/B.A._Eagle_2" title="B.A. Eagle 2" class="mw-redirect">B.A. Eagle 2</a></li>
<li><a href="/wiki/B.A._Double_Eagle" title="B.A. Double Eagle" class="mw-redirect">B.A. Double Eagle</a></li>
</ul>
我需要在HTML标签之间找到一个值,例如 B.A.C。然后使用VBA实际进入包含
B.A.C的订单项的链接
。在我导航之后,我需要得到一个字符串中得到的URL。请记住,如果可能,我需要高度偏好绑定。我试图写一个循环,但没有成功... href
。 VII
I need to find one value between the HTML tags for example B.A.C. VII
and then use VBA to actually go in to the link href
of the line item which holds B.A.C. VII
. After i have navigated there i need to get the resulting URL in a String. Keep in mind that i need highly prefer binding if possible. I tried to write a loop but with no success...
亲爱的罗恩
调试器停在第一个line andd ...
给我运行时错误'424'
但是我们有一个对象限定符无处不在...
Debugger stops on the first line andd...
It giving me Run-time error '424'
however we have an object qualifier everywhere...
感谢我的问题
推荐答案
这个循环适用于我。
Sub test()
' open IE, navigate to the website of interest and loop until fully loaded
Set IE = CreateObject("InternetExplorer.Application")
my_url = "http://www.xyz.com"
With IE
.Visible = True
.navigate my_url
.Top = 50
.Left = 530
.Height = 400
.Width = 400
Do Until Not IE.Busy And IE.readyState = 4
DoEvents
Loop
End With
' Find the desired url and click
Set Results = IE.document.getElementsByTagName("a")
For Each itm In Results
If itm.outerhtml = "B.A.C. VII" Then
itm.Click
Do Until Not IE.Busy And IE.readyState = 4
DoEvents
Loop
Exit For
End If
Next
End Sub
这篇关于vba解析href的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!