shahin
Active Member
I've written a script in vba to get some unwanted links started with "#" using "Like" operator from a webpage. I could sift through the links If I opt for "Instr()" function. However, my intention is to grab those links using "Like" operator. How can I modify my script to get them?
Usual links look like:
The ones I wish to grab look like:
My script can grab all of the types but I wish to stick to grab only the links started with "#".
This is my attempt so far:
Usual links look like:
Code:
javascript:document.form1.submit();
The ones I wish to grab look like:
Code:
#top
My script can grab all of the types but I wish to stick to grab only the links started with "#".
This is my attempt so far:
Code:
Sub ClickLinks()
Const Url As String = "https://intraweb.stockton.edu/eyos/page.cfm?siteID=58&pageID=7&action=dirmain&type=FAC&display=basic"
Dim IE As New InternetExplorer, Htmldoc As HTMLDocument, I&
With IE
.Visible = True
.navigate Url
While .Busy = True Or .readyState < 4: DoEvents: Wend
Set Htmldoc = .document
End With
With Htmldoc.querySelectorAll("#main table tr a")
For I = 0 To .Length - 1
If .Item(I).getAttribute("href") Like "#*" Then 'can't fix this line to get the links started with #
Cells(I + 1, 1) = .Item(I).getAttribute("href")
End If
Next I
End With
IE.Quit
End Sub