Results 1 to 7 of 7

Thread: [RESOLVED] Site title

  1. #1

    Thread Starter
    Fanatic Member vivek_master146's Avatar
    Join Date
    Apr 2006
    Location
    Delhi,India
    Posts
    787

    Resolved [RESOLVED] Site title

    Hi all,
    I want to know how to get the title of a website through vb.
    Example: yahoo has a title "Yahoo! - Microsoft Internet Explorer"
    I used webbrowser and inet but i did not found any such property. I am making a project for which i need this to be done.

  2. #2
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: Site title

    VB Code:
    1. Private Sub Form_Load()
    2.     Dim strdata As String
    3.     strURL = Trim(InputBox("Please enter URL"))
    4.     If Len(strURL) < 1 Then
    5.         MsgBox "No URL selected"
    6.     Else
    7.         Inet1.URL = strURL
    8.         strdata = Inet1.OpenURL(Inet1.URL)
    9.         DoEvents
    10.         Strt = InStr(1, LCase(strdata), "<title>")
    11.         Fnsh = InStr(1, LCase(strdata), "</title>")
    12.         MsgBox Mid(strdata, Strt + Len("<title>"), Fnsh - Strt - Len("<title>"))
    13.     End If
    14. End Sub

  3. #3

    Thread Starter
    Fanatic Member vivek_master146's Avatar
    Join Date
    Apr 2006
    Location
    Delhi,India
    Posts
    787

    Angry Re: Site title

    hi,
    good code! but this is not code i wanted. this is only for html sites by finding the text from html code between <title> and </title>. i wanted for all sites made in asp and php languages like when i am entering www.planet-source-code.com then it is showing error beacuse it is made in asp.

  4. #4
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Site title

    That code should work for other languages too.
    If it doesn't work then you could get the text in the metadata 'title', but not all sites contain this
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  5. #5
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: Site title

    Ok how bout this using the Webbrowser control
    VB Code:
    1. Private Sub Form_Load()
    2.     Dim strdata As String
    3.     strUrl = Trim(InputBox("Please enter URL"))
    4.     If Len(strUrl) < 1 Then
    5.         MsgBox "No URL selected"
    6.     Else
    7.         WebBrowser1.Navigate2 strUrl
    8.     End If
    9. End Sub
    10. Private Sub WebBrowser1_TitleChange(ByVal Text As String)
    11. If Text = "" Then Exit Sub
    12. MsgBox Text
    13. End Sub

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,651

    Re: Site title

    Quote Originally Posted by vivek_master146
    hi,
    good code! but this is not code i wanted. this is only for html sites by finding the text from html code between <title> and </title>. i wanted for all sites made in asp and php languages like when i am entering www.planet-source-code.com then it is showing error beacuse it is made in asp.
    ASP, ASP.NET, and PHP, are server-side tools used to output HTML code. Browsers do not understand any languages (except Javascript), only markup.

    There should be no problem with PSC, because their title is contained within <title> and </title>. Can you post the error message you got when you tried that site?

  7. #7

    Thread Starter
    Fanatic Member vivek_master146's Avatar
    Join Date
    Apr 2006
    Location
    Delhi,India
    Posts
    787

    Re: Site title

    hi all,
    i got it. when i saw in the debug mode i got the error that the data is overloaded. please try after sometime. otherwise the inet control is good to get a tilte of any site.

    Thanks for help.

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