Link to home
Start Free TrialLog in
Avatar of saeelo
saeelo

asked on

URL search

experts,
I have been working on a google URL extractor i need your help with link search:

what i want to do now just add to the listbox all the link that contain :"asp?=" i am not able to find a way i thought of using a inbetween technique but it wont work because i never know how is the end of the link, any advise?
' visual basic 6.0
For x = 0 To WebBrowser1.Document.links.length - 1
If Left(WebBrowser1.Document.links(x), 9) <> "http://74" And Left(WebBrowser1.Document.links(x), 17) <> "http://www.google" And Left(WebBrowser1.Document.links(x), 18) <> "https://www.google" And Left(WebBrowser1.Document.links(x), 13) <> "http://images" And Left(WebBrowser1.Document.links(x), 11) <> "http://news" And Left(WebBrowser1.Document.links(x), 13) <> "http://groups" And Left(WebBrowser1.Document.links(x), 11) <> "http://mail" And Left(WebBrowser1.Document.links(x), 11) <> "http://docs" And Left(WebBrowser1.Document.links(x), 14) <> "http://scholar" And Left(WebBrowser1.Document.links(x), 12) <> "http://sites" And Left(WebBrowser1.Document.links(x), 16) <> "http://translate" Then
Debug.Print WebBrowser1.Document.links(x)
   End If
Next

Open in new window

Avatar of Praveen Venu
Praveen Venu
Flag of India image

try

(WebBrowser1.Document.links(x).ToString().Contains(".asp?")

this will return true if it contains the string "asp?"
Avatar of saeelo
saeelo

ASKER

i will try it now praveenvenu thank you i ll keep u updated
ASKER CERTIFIED SOLUTION
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
First: Instead of using Left(...) try using x.Startwith("http://...)
Second, use a x.Contains("asp?=") to detect if it is an asp page.
Avatar of saeelo

ASKER

yes it is vb6.0
thank you guys for helping, but still i tried to implement the x.contains ("asp?=) it gave me a mismatch error what i am trying to do now is just to populate a listbox with all the .asp page that has parameters. and ignore the rest. i just can't find the right way. i ll try to use x.startwith rseabird just trying to find a solution for this problem
thank you for ur help
Private Sub Command1_Click()
Dim oLink As Object
 
WebBrowser1.Navigate Text1.Text
 
Do While WebBrowser1.Busy
    DoEvents
Loop
 
For x = 0 To WebBrowser1.Document.links.length - 1
If Left(WebBrowser1.Document.links(x), 9) <> "http://74" And Left(WebBrowser1.Document.links(x), 17) <> "http://www.google" And Left(WebBrowser1.Document.links(x), 18) <> "https://www.google" And Left(WebBrowser1.Document.links(x), 13) <> "http://images" And Left(WebBrowser1.Document.links(x), 11) <> "http://news" And Left(WebBrowser1.Document.links(x), 13) <> "http://groups" And Left(WebBrowser1.Document.links(x), 11) <> "http://mail" And Left(WebBrowser1.Document.links(x), 11) <> "http://docs" And Left(WebBrowser1.Document.links(x), 14) <> "http://scholar" And Left(WebBrowser1.Document.links(x), 12) <> "http://sites" And Left(WebBrowser1.Document.links(x), 16) <> "http://translate" Then
Debug.Print WebBrowser1.Document.links(x)
   End If
Next
MsgBox "done"
 
End Sub

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Have you looked to my solution ?
Avatar of saeelo

ASKER

thank you guys, i splited the point between you 2 because both of the comments were helpfull thank you so much again
Glad I could help!
Contains(), StartWith, IndexOf() are all methods of .NET. Since you have choose an .NET zone, almost all the comments where in .NET.