Sharid
Well-known Member
- Joined
- Apr 22, 2007
- Messages
- 1,066
- Office Version
- 2016
- Platform
- Windows
Hi
Is there a way of getting certain pages urls from a website using vba.
My following code gets all the urls from a web site page. I enter the domain in L1 and whatever that domain is, it will go to that page and extract all urls.
The problem is
1) It only extracts from that page
2) Not all the urls are correct, it extracts all links.
I need it to go to the domain and then extract All urls that have a specified word in them e.g.
If i placed the url https://www.mrexcel.com/ in sheet1 L1 and then I typed a Specified word in Sheet1 A1 like forum or excel-questions. It would check the domain mrexcel for all urls with that keyword and extract the urls
https://www.mrexcel.com/forum/excel-questions/
thanks for having a look
Is there a way of getting certain pages urls from a website using vba.
My following code gets all the urls from a web site page. I enter the domain in L1 and whatever that domain is, it will go to that page and extract all urls.
The problem is
1) It only extracts from that page
2) Not all the urls are correct, it extracts all links.
Code:
Sub EstraiURLdaWeb()
Dim doc As HTMLDocument
Dim output As Object
Set IE = New InternetExplorer
IE.Visible = False
IE.navigate Range("L1")
Do
DoEvents
Loop Until IE.readyState = READYSTATE_COMPLETE
Set doc = IE.document
Set output = doc.getElementsByTagName("a")
i = 5
For Each link In output
Range("A" & i).Value = link
i = i + 1
Next
MsgBox "All Done!"
End Sub
I need it to go to the domain and then extract All urls that have a specified word in them e.g.
If i placed the url https://www.mrexcel.com/ in sheet1 L1 and then I typed a Specified word in Sheet1 A1 like forum or excel-questions. It would check the domain mrexcel for all urls with that keyword and extract the urls
https://www.mrexcel.com/forum/excel-questions/
thanks for having a look