Jump to content

Grab links

- - - - -

  • Please log in to reply
25 replies to this topic

#1
martin2311

martin2311

    Learning Programmer

  • Members
  • PipPipPip
  • 32 posts
hey guys i want to use web browser and use text box to search google
i want to add all the url in the list box but i don`t get that regex thing any helps please or any source code?

and i am using vb .net 2008

#2
CommittedC0der

CommittedC0der

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,565 posts
You want to add the URL from the textBox to the listBox? Or are you trying to get the searched words out of the Google URL? I cant really tell what your trying to do.

~ Committed.
A man can be defined by what he does when no one is looking.
Science is only an educated theory, which we cannot disprove.

#3
martin2311

martin2311

    Learning Programmer

  • Members
  • PipPipPip
  • 32 posts
bro all i want to do is to search a word and get all the websites that google shows for that word in a list box

in other words all urls of search

#4
CommittedC0der

CommittedC0der

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,565 posts
Try looking at this:(The reply's are at the very bottom)
regEx for pulling out google links : c# google
its in C# but you should be able to convert it.
Convert C# to VB.NET - A free code conversion tool - developer Fusion
Good luck ~ Committed.
A man can be defined by what he does when no one is looking.
Science is only an educated theory, which we cannot disprove.

#5
martin2311

martin2311

    Learning Programmer

  • Members
  • PipPipPip
  • 32 posts
well it says subscribe :S but i`ll take a look at this thanks bro i hope that would help

#6
martin2311

martin2311

    Learning Programmer

  • Members
  • PipPipPip
  • 32 posts
Private Sub test14()

	Dim w As New WebClient()

	Dim pageSource As String = w.DownloadString("http://www.google.com/search?hl=en&q=weather&start=0")

	Dim s As String = "(?<=<h3 class=r><a href="")([^""]+)"

	Dim re As New Regex(s)

	Dim m As MatchCollection = re.Matches(pageSource)

	For i As Integer = 0 To m.Count - 1

		Debug.Print("Match result {0} is ""{1}"".", i, m(i))

	Next

End Sub


well this is converted and uses webrequest i want to use web browser :( and its a bit confusing for me

#7
CommittedC0der

CommittedC0der

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,565 posts
You can still use your webBrowser just change this line
Dim pageSource As String = w.DownloadString("http://www.google.com/search?hl=en&q=weather&start=0")
to something like:
Dim pageSource As String = w.DownloadString(webBrowser1.Url.ToString())
Then when some clicks the search button or whatever, just call the function.
Forgive me as im not really an expert with VB. ~ Committed. :)
A man can be defined by what he does when no one is looking.
Science is only an educated theory, which we cannot disprove.

#8
martin2311

martin2311

    Learning Programmer

  • Members
  • PipPipPip
  • 32 posts
well atleast you are good tht u can modify tht even after tht i don`t get it how to use it :(

#9
martin2311

martin2311

    Learning Programmer

  • Members
  • PipPipPip
  • 32 posts
well i did tht to get source code of the page
the next problem is that how can i make regex of this ??

<a href="http://www.ourbrisbane.com/see-and-do/places-to-see/valley-lakes" class="l" onmousedown="return clk(this.href,'','','','10','','0CFoQFjAJ')">


i just want the url "http://www.ourbrisbane.com/see-and-do/places-to-see/valley-lakes" this thing out of this from all sites how to make regex for this?


m doing it like
Dim r As System.Text.RegularExpressions.Regex((""<a href=""http://.*"" class=""l"")

but i get the error how to fix it?

#10
CommittedC0der

CommittedC0der

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,565 posts
Hmm the Regex looks fine to me, could you post the error your receiving?
A man can be defined by what he does when no one is looking.
Science is only an educated theory, which we cannot disprove.

#11
martin2311

martin2311

    Learning Programmer

  • Members
  • PipPipPip
  • 32 posts
the error says array bound cannot appear in type specifiers

this source i took from mozilla firefox but the source i get using internet explorer is different how to get that fixed?

#12
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
If you are wanting just URL addresses, the following regular expression should work:
((?:http|https)(?::\/{2}[\w]+)(?:[\/|\.]?)(?:[^\s""]*))

Although I think you may need to be a little more specific, are you wanting more than just the URL?
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users