|
-
Feb 13th, 2008, 10:56 AM
#1
Thread Starter
Banned
How to get the title of a web page?
Hot to get the title of a web HTML page, if the title is between <title> and </title> tags?
Help me to get the text that is between these tags:
<title>
Title page here
</title>
-
Feb 13th, 2008, 11:24 AM
#2
Fanatic Member
Re: How to get the title of a web page?
Hi AlexVorn,
I think that this is not the proper forum to ask the question but if you use the command me.title in the code behind page it will return the page title like you want.
Hope this helps
CLanguage; 
IF Post = HelpFull Then
RateMe
Else
Say("Shut UP")
End If
DotNet rocks
VB 6, VB.Net 2003, 2005, 2008, 2010, SQL 2005, WM 5.0,ahem ?OpenRoad?
-
Feb 13th, 2008, 12:09 PM
#3
Lively Member
Re: How to get the title of a web page?
cool tip c language wrong place for asp question
-
Feb 13th, 2008, 12:43 PM
#4
Re: How to get the title of a web page?
-
Feb 13th, 2008, 02:55 PM
#5
Thread Starter
Banned
Re: How to get the title of a web page?
@stanav, could u give some codes?
-
Feb 13th, 2008, 03:35 PM
#6
Re: How to get the title of a web page?
 Originally Posted by AlexVorn
@stanav, could u give some codes?
Sure... Try something like this
Code:
Dim html As String = "your html code goes here"
Dim pattern As String = "(?<=\<title\>)[a-zA-Z0-9\s]*(?=\</title\>)"
Dim m As System.Text.RegularExpressions.Match = System.Text.RegularExpressions.Regex.Match(html, pattern)
Dim title As String = m.Value
MessageBox.Show(title)
-
Feb 13th, 2008, 05:21 PM
#7
Re: How to get the title of a web page?
if you are navigating the webpage with a webbrowser, you can use Document.Title, eg:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
wb.Navigate("http://www.google.co.uk")
End Sub
Private Sub wb_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles wb.DocumentCompleted
Console.WriteLine(wb.Document.Title)
End Sub
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Feb 13th, 2008, 05:31 PM
#8
Re: How to get the title of a web page?
You mentioned 'asp' but posted in the vb.net section, so I'll assume you're using ASP.NET rather than classic ASP.
To get the title of a page, use HttpWebRequest's Response to read the page into a string, and then use stanav's code to find the title.
If you want to get the title of the page you're currently on, use Page.Header.Title.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|