We help IT Professionals succeed at work.

URL search

Medium Priority
271 Views
Last Modified: 2013-12-25
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

Comment
Watch Question

Praveen VenuTechnical Project Manager

Commented:
try

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

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

Author

Commented:
i will try it now praveenvenu thank you i ll keep u updated
IT Pro/Developer
CERTIFIED EXPERT
Top Expert 2008
Commented:
It's .NET or VB6 ? You have VB6 in the code snippet.
If it's VB6 you can use

Dim webPage As String
webPage = "www.mypage.asp?=3"
 
If InStr(1, webPage, "asp", vbTextCompare) Then
    MsgBox "Text found!"
End If

Open in new window

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Commented:
First: Instead of using Left(...) try using x.Startwith("http://...)
Second, use a x.Contains("asp?=") to detect if it is an asp page.

Author

Commented:
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

Praveen VenuTechnical Project Manager
Commented:

if InStr(1, WebBrowser1.Document.links(x),"asp?", vbTextCompare)>0 then
 'it contains parameter
end if

Open in new window

Jorge PaulinoIT Pro/Developer
CERTIFIED EXPERT
Top Expert 2008

Commented:
Have you looked to my solution ?

Author

Commented:
thank you guys, i splited the point between you 2 because both of the comments were helpfull thank you so much again
Jorge PaulinoIT Pro/Developer
CERTIFIED EXPERT
Top Expert 2008

Commented:
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.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.