Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

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

0
saeelo
Asked:
saeelo
  • 3
  • 3
  • 2
  • +1
2 Solutions
 
Praveen VenuCommented:
try

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

this will return true if it contains the string "asp?"
0
 
saeeloAuthor Commented:
i will try it now praveenvenu thank you i ll keep u updated
0
 
jpaulinoCommented:
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

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
rseabirdCommented:
First: Instead of using Left(...) try using x.Startwith("http://...)
Second, use a x.Contains("asp?=") to detect if it is an asp page.
0
 
saeeloAuthor 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

0
 
Praveen VenuCommented:

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

Open in new window

0
 
jpaulinoCommented:
Have you looked to my solution ?
0
 
saeeloAuthor Commented:
thank you guys, i splited the point between you 2 because both of the comments were helpfull thank you so much again
0
 
jpaulinoCommented:
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.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now