Results 1 to 25 of 25

Thread: [RESOLVED]Web Browser Help to show list of urls instead of web page ?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2008
    Posts
    314

    Arrow [RESOLVED]Web Browser Help to show list of urls instead of web page ?

    Hi Guys I been working on search/webbrowser

    Here is the thing at the moment I have a list box and i have a text field I also have a drop down box so u can select which search angine to use


    My problem is this when I type in the search Box it opens up my internet explorer and shows me in search there what I typed in my program

    Instead I want my program to display list of urls in my list box.. this is what my cod looks like at the moment

    Code:
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            If TextBox1.Text = "" Then
                MsgBox("Error,You aeent gonna find poop with no word in search", MsgBoxStyle.Critical)
            Else
                If ComboBox1.Text = "Google" Then
                    System.Diagnostics.Process.Start("http://www.google.co.uk/search?q=" + TextBox1.Text + "&btnG=Search&meta=")
                End If
            End If
        End Sub
    End Class

    Could some one help me out please so that when I hit Go it will display list of urls in my list box no info just web url in list format

    Thanks guys
    Last edited by Breez; Aug 29th, 2009 at 12:48 AM.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: Web Browser Help to show list of urls instead of web page ?

    you could use the net.webclient class to download the html generated by your search on google. then you need to parse the html to extract the links

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2008
    Posts
    314

    Re: Web Browser Help to show list of urls instead of web page ?

    Quote Originally Posted by .paul. View Post
    you could use the net.webclient class to download the html generated by your search on google. then you need to parse the html to extract the links
    can u post example please?

  4. #4
    Hyperactive Member BadgerBadger's Avatar
    Join Date
    Aug 2009
    Location
    Wales
    Posts
    382

    Re: Web Browser Help to show list of urls instead of web page ?

    You can use RegEx patterns to grab the links.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2008
    Posts
    314

    Re: Web Browser Help to show list of urls instead of web page ?

    guys I have no clue what u talking about VB 2008 is new to me can u post me a eather example or Tutorial Links I can look at so i can achive what I want please?

  6. #6
    Hyperactive Member BadgerBadger's Avatar
    Join Date
    Aug 2009
    Location
    Wales
    Posts
    382

    Re: Web Browser Help to show list of urls instead of web page ?

    OK, search for the WebClient class as Paul mentioned and check out http://www.regular-expressions.info/ to find out how to grab links/urls from the HTML source.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2008
    Posts
    314

    Re: Web Browser Help to show list of urls instead of web page ?

    Quote Originally Posted by BadgerBadger View Post
    OK, search for the WebClient class as Paul mentioned and check out http://www.regular-expressions.info/ to find out how to grab links/urls from the HTML source.


    Ok I searched for WebClient class and Im getting bunch of links that arnt any good to me does no one have tutorial on WebClient class ??? easy explained? Pleaese

  8. #8
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: Web Browser Help to show list of urls instead of web page ?

    heres how to get the html.

    vb Code:
    1. dim wc as new net.webclient
    2. dim html as string = wc.downloadstring("http://www.google.co.uk/search?q=" + TextBox1.Text + "&btnG=Search&meta=")

    maybe someone else can help you extract the urls

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2008
    Posts
    314

    Re: Web Browser Help to show list of urls instead of web page ?

    Thanks Paul

    Now My code looks like this

    Code:
    Public Class Form1
    Imports System.Net
    Imports System.Text.RegularExpressions
    
        Public Class Form1
    
            Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                Dim wc As New WebClient
                Dim URIsearch As String
                Dim URImatches As MatchCollection
                Dim i As Integer = 0
    
                URIsearch = wc.DownloadString("http://www.google.com/search?source=ig&hl=en&rlz=&=&q=counter+strike&btnG=Google+Search").ToString()
    
                URImatches = Regex.Matches(URIsearch, "((http\://|https\://|ftp\://)|(www.))+(([a-zA-Z0-9\.-]+\.[a-zA-Z]{2,4})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(/[a-zA-Z0-9%:/-_\?\.'~]*)?")
    
                For Each item As Match In URImatches
                    i += 1
                    lstURIlist.Items.Add(item.Value)
                Next item
            End Sub
        End Class
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            If TextBox1.Text = "" Then
                MsgBox("Error,You aeent gonna find **** with no dorks", MsgBoxStyle.Critical)
            Else
                If ComboBox1.Text = "Google" Then
                    System.Diagnostics.Process.Start("http://www.google.co.uk/search?q=" + TextBox1.Text + "&btnG=Search&meta=")
                End If
                If ComboBox1.Text = "Yahoo" Then
                    System.Diagnostics.Process.Start("http://uk.search.yahoo.com/search?rd=r1&p=" + TextBox1.Text + "&btnG=Search&meta=")
                End If
            End If
        End Sub
    End Class

    and it's giving me this errors


    Code:
    Error	1	'Imports' statements must precede any declarations.	C:\Documents and Settings\Breez\Local Settings\Application Data\Temporary Projects\WindowsApplication1\Form1.vb	2	1	WindowsApplication1
    Error	2	'Imports' statements must precede any declarations.	C:\Documents and Settings\Breez\Local Settings\Application Data\Temporary Projects\WindowsApplication1\Form1.vb	3	1	WindowsApplication1
    Error	3	Event 'Load' cannot be found.	C:\Documents and Settings\Breez\Local Settings\Application Data\Temporary Projects\WindowsApplication1\Form1.vb	7	107	WindowsApplication1
    Error	4	Type 'WebClient' is not defined.	C:\Documents and Settings\Breez\Local Settings\Application Data\Temporary Projects\WindowsApplication1\Form1.vb	8	27	WindowsApplication1
    Error	5	Type 'MatchCollection' is not defined.	C:\Documents and Settings\Breez\Local Settings\Application Data\Temporary Projects\WindowsApplication1\Form1.vb	10	31	WindowsApplication1
    Error	6	Name 'Regex' is not declared.	C:\Documents and Settings\Breez\Local Settings\Application Data\Temporary Projects\WindowsApplication1\Form1.vb	15	26	WindowsApplication1
    Error	7	Type 'Match' is not defined.	C:\Documents and Settings\Breez\Local Settings\Application Data\Temporary Projects\WindowsApplication1\Form1.vb	17	30	WindowsApplication1

  10. #10
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: Web Browser Help to show list of urls instead of web page ?

    vb Code:
    1. Imports System.Net
    2. Imports System.Text.RegularExpressions
    3.  
    4. Public Class Form1
    5.  
    6.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    7.         Dim wc As New WebClient
    8.         Dim URIsearch As String
    9.         Dim URImatches As MatchCollection
    10.         Dim i As Integer = 0
    11.  
    12.         URIsearch = wc.DownloadString("http://www.google.com/search?source=ig&hl=en&rlz=&=&q=counter+strike&btnG=Google+Search").ToString()
    13.  
    14.         URImatches = Regex.Matches(URIsearch, "((http\://|https\://|ftp\://)|([url]www.))+(([/url][a-zA-Z0-9\.-]+\.[a-zA-Z]{2,4})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(/[a-zA-Z0-9%:/-_\?\.'~]*)?")
    15.  
    16.         For Each item As Match In URImatches
    17.             i += 1
    18.             lstURIlist.Items.Add(item.Value)
    19.         Next item
    20.     End Sub
    21.    
    22. End Class

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2008
    Posts
    314

    Re: Web Browser Help to show list of urls instead of web page ?

    Thanks paul I did get it sorted last night by help of Sup on msn now the problem I have all my urls in list box are showing up great

    Problem is when I click url in my list box its not opening up web page or anything :s what m I doing wrong?

  12. #12
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: Web Browser Help to show list of urls instead of web page ?

    try this:

    vb Code:
    1. Private Sub ListBox1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDoubleClick
    2.     If ListBox1.IndexFromPoint(e.Location) <> -1 Then
    3.         process.start(listbox1.selecteditem.tostring)
    4.     End If
    5. End Sub

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2008
    Posts
    314

    Re: Web Browser Help to show list of urls instead of web page ?

    Thanks Paul I have tryed your above code still no luck it will not let me open urls when i click it in my list box

  14. #14
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: Web Browser Help to show list of urls instead of web page ?

    can you post an example of a url from your listbox?

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2008
    Posts
    314

    Re: Web Browser Help to show list of urls instead of web page ?


  16. #16
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: Web Browser Help to show list of urls instead of web page ?

    did you realise thats the mousedoubleclick event?
    if you want to launch the url on a single click, use the ListBox1_SelectedIndexChanged event:

    vb Code:
    1. Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
    2.     If ListBox1.SelectedIndex <> -1 Then
    3.         Process.Start(ListBox1.SelectedItem.ToString)
    4.     End If
    5. End Sub

  17. #17
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: Web Browser Help to show list of urls instead of web page ?

    you might find the ListBox1_MouseClick event works better:

    vb Code:
    1. Private Sub ListBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseClick
    2.     If ListBox1.IndexFromPoint(e.Location) <> -1 Then
    3.         process.start(listbox1.selecteditem.tostring)
    4.     End If
    5. End Sub

  18. #18

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2008
    Posts
    314

    Re: Web Browser Help to show list of urls instead of web page ?

    Thanks Paul that worked Great

    Now problem I'm having some reason my search list is searching in all types of directories like

    books.google.com
    images.google.com
    calendar.google,com
    video.google.com


    How can I doit so that it will just search on web on its own and not other directories ? so if I type in Test

    Instead of google giving me resaults for all the googles sites for test I want resault to show me as normal search like u would in google if u know what I mena ?

  19. #19
    Hyperactive Member BadgerBadger's Avatar
    Join Date
    Aug 2009
    Location
    Wales
    Posts
    382

    Re: Web Browser Help to show list of urls instead of web page ?

    You could modify your RegEx pattern so it doesn't grab extra periods. Unfortunately I'm not the most suitable when it comes to RegEx, so maybe someone else can help you if you get confused.

  20. #20

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2008
    Posts
    314

    Re: Web Browser Help to show list of urls instead of web page ?

    Thanks for your replly badger I will waite til lsomeone knows what I need to edit so I can fix this issue

  21. #21

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2008
    Posts
    314

    Re: Web Browser Help to show list of urls instead of web page ?

    any one please?

  22. #22
    Hyperactive Member BadgerBadger's Avatar
    Join Date
    Aug 2009
    Location
    Wales
    Posts
    382

    Re: Web Browser Help to show list of urls instead of web page ?

    I suggest making a new thread as you will most likely get help within a small amount of time.

  23. #23
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: Web Browser Help to show list of urls instead of web page ?

    Quote Originally Posted by BadgerBadger View Post
    I suggest making a new thread as you will most likely get help within a small amount of time.
    me too. you'll get a quicker reply

  24. #24
    Fanatic Member Seraph's Avatar
    Join Date
    Jul 2007
    Posts
    959

    Re: Web Browser Help to show list of urls instead of web page ?

    My name is Seraph not Sup. lol

    And just for reference, it is actually getting ANY web address in the HTML source code since there isn't really a way to tell the difference between a search result any of the web addresses that google puts in there statically.

    The Regex has to be able to return rather complex webpage addresses because the google search results for webpages can have any number of weird characters and patterns in them.

    Those first google.com addresses are the links you see on google pages in the top left corner:
    Web Images Videos Maps News Shopping Gmail more
    This can't be helped unless you can find some discernable pattern as to where search result webpages start and end, therefore being able to effectively get rid of non search result-based addresses.

    In short, it's not the RegEx that is the issue, it's how to determine the difference between a search result web address or just a normal link that would be on any search result page.

    I helped him with the code to get the google search page and get the web addresses out. I didn't feel like looking into the pattern of the website.
    Last edited by Seraph; Aug 28th, 2009 at 03:04 PM.

    Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7

    SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
    [Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]

    [.NET and MySQL Quick Guide]

  25. #25

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2008
    Posts
    314

    Re: Web Browser Help to show list of urls instead of web page ?

    Thanks Seraph for that Info but I was wondering of there was an easyer way of achiving this ?

    As u know list box allready returning the list but not the search list liek u would in google
    instead grabing them from all the groups

    I think I will make a another thread about this see if I could get some help as thats what I need my program doing thanks for all your help guys I have add it some reps

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width