shahin
Active Member
Well, I expect to curtail links as "https://yts.ag/","https://chandoo.org","https://www.wiseowl.co.uk" instead.
If pattern match "^about:/" then replace it with appropriate absolute link for each site.
... like I wrote. Replace 'about:/' with root directory/path
…
FYI - instead of SPLIT function, use REPLACE function.
So when you read a link starting with "about:/" just replace it
by the correct domain or base of URL you already wrote on a paper
when you manually observed the webpage.
Or just use Replace VBA function …
So I can't see any R E P L A C E within your code ‼Unclear … No needs to filter but to replace "about:" !
Sub Demo4Noob()
For Each V In [{"http://siteA","about:siteB","http://siteC"}]
Debug.Print Replace(V, "about:", "http://")
Next
End Sub
Sub Demo()
Dim storage As String, arr() As String, items
storage = "https://www.yify-torrent.org/search/1080p/," & _
"https://yts.ag/browse-movies,https://www.houzz.com/professionals," & _
"https://www.wiseowl.co.uk/videos/"
arr() = Split(storage, ",")
For Each items In arr
x = Split(Replace(Replace(items, "/", "@", 1, 3), "@", "/", 1, 2), "@")
Debug.Print x(0)
Next
End Sub
Sub Demo()
Dim storage As String, arr() As String, items
storage = "https://www.yify-torrent.org/search/1080p/," & _
"https://yts.ag/browse-movies,https://www.houzz.com/professionals," & _
"https://www.wiseowl.co.uk/videos/"
arr() = Split(storage, ",")
For Each items In arr
x = Left(items, InStr(9, items, "/") - 1)
Debug.Print x
Next
End Sub
Hmm? I gave you one already in post #14could you provide me with any link that can lead me to a regex tutorial?
Sub Creating_absolute_links()
Dim http As New XMLHTTP60, html As New HTMLDocument
Dim post As Object, vault As Variant, link As Variant
vault = Array( _
"https://yts.ag/browse-movies/", _
"https://chandoo.org/wp/vba-classes/", _
"https://www.wiseowl.co.uk/videos/")
For Each link In vault
With http
.Open "GET", link, False
.send
html.body.innerHTML = .responseText
End With
For Each post In html.getElementsByTagName("a")
If InStr(link, "http:") > 0 Then
x = Left(link, InStr(8, link, "/") - 1)
Else: x = Left(link, InStr(9, link, "/") - 1)
End If
If InStr(post.href, "about:/") > 0 Then r = r + 1: Cells(r, 1) = x & Split(post.href, "about:")(1)
Next post
Next link
End Sub
Sub Link_parser()
Dim http As New XMLHTTP60, html As New HTMLDocument
Dim post As Object, link_var As Variant, link As Variant
link_var = Array( _
"http://spltech.in/", _
"http://www.unifrostindia.com/", _
"http://advanta.in/", _
"http://www.superrefrigerations.com/", _
"http://www.greenplanet.in/")
For Each link In link_var
With http
.Open "GET", link, False
.send
html.body.innerHTML = .responseText
End With
For Each post In html.getElementsByTagName("a")
If InStr(link, "http:") > 0 Then x = Left(link, InStr(8, link, "/") - 1)
If InStr(1, post.innerText, "contact", 1) > 0 Then refined_links = post.href: Exit For
' If InStr(1, refined_links, "about:", 1) > 0 Then
' R = R + 1: Cells(R, 1) = x & Split(refined_links, "about:")(1)
' Else:
' R = R + 1: Cells(R, 1) = refined_links
' End If
Next post
Debug.Print refined_links
Next link
End Sub
about:contactus.aspx
http://www.unifrostindia.com/contactus
about:contact.html
about:contactus.htm
http://www.greenplanet.in/contact-us.htm