Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > ASP.NET 4 General Discussion
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 4th, 2011, 08:57 PM
Authorized User
Points: 221, Level: 4
Points: 221, Level: 4 Points: 221, Level: 4 Points: 221, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2010
Posts: 55
Thanks: 9
Thanked 0 Times in 0 Posts
Default how to i get other web meta tags?

somebody know how?

i mean that i have textbox and button,and for the example textbox.text=http://google.com and then the press button recall from google the meta tags.. like descrption and title...
Reply With Quote
  #2 (permalink)  
Old August 5th, 2011, 03:00 AM
irishelnsman928
Guest
 
Posts: n/a
Default hello im new here!!!

pole fitness denver - pole dancing denver - laser back surgery
Reply With Quote Received Infraction
  #3 (permalink)  
Old August 5th, 2011, 03:54 AM
Imar's Avatar
Wrox Author
Points: 72,022, Level: 100
Points: 72,022, Level: 100 Points: 72,022, Level: 100 Points: 72,022, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,076
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

You can use the WebRequest class to request the page and then retrieve its HTML. You can then parse the HTML for the requestes meta tags. For that you could use the HTML Agility Pack: http://htmlagilitypack.codeplex.com/

For both techniques you'll find plenty of examples on Google.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
nir987 (August 5th, 2011)
  #4 (permalink)  
Old August 5th, 2011, 05:12 PM
Authorized User
Points: 221, Level: 4
Points: 221, Level: 4 Points: 221, Level: 4 Points: 221, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2010
Posts: 55
Thanks: 9
Thanked 0 Times in 0 Posts
Default

but how i get the meta with WebRequest?
i found in google alot of thing but icant get the meta tag...
Reply With Quote
  #5 (permalink)  
Old August 5th, 2011, 06:27 PM
Imar's Avatar
Wrox Author
Points: 72,022, Level: 100
Points: 72,022, Level: 100 Points: 72,022, Level: 100 Points: 72,022, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,076
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Take a look here: http://www.google.com/#sclient=psy&h...ack++find+meta

The first result is a SO post with sample code, but there are many more examples available.

Cheers,
Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
nir987 (August 5th, 2011)
  #6 (permalink)  
Old August 5th, 2011, 09:18 PM
Authorized User
Points: 221, Level: 4
Points: 221, Level: 4 Points: 221, Level: 4 Points: 221, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2010
Posts: 55
Thanks: 9
Thanked 0 Times in 0 Posts
Default

how do i make it work
PHP Code:
    Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgsHandles Me.Load

        Dim doc 
As New HtmlDocument
        doc
.LoadHtml("http://p2p.wrox.com")
        
Dim node As HtmlNode doc.DocumentNode.SelectSingleNode("//meta[@name='description']")



        If 
node.ToString Not Nothing Then
            Dim str 
As String node.GetAttributeValue("content""")


        
End If

    
End Sub 

?
Reply With Quote
  #7 (permalink)  
Old August 6th, 2011, 06:33 AM
Imar's Avatar
Wrox Author
Points: 72,022, Level: 100
Points: 72,022, Level: 100 Points: 72,022, Level: 100 Points: 72,022, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,076
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Did you read the documentation that comes with the HTML Agility Pack? LoadHtml expects an HTML string, not a Web URL.

As hinted in my first reply, you need to use WebRequest to request the page, grab its HTML and feed that to LoadHtml.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #8 (permalink)  
Old August 6th, 2011, 02:15 PM
Authorized User
Points: 221, Level: 4
Points: 221, Level: 4 Points: 221, Level: 4 Points: 221, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2010
Posts: 55
Thanks: 9
Thanked 0 Times in 0 Posts
Default

PHP Code:
       Dim URL As String "http://www.youtube.com/watch?v=66rY3wHSneA"
        
Dim request As WebRequest WebRequest.Create(URL)
        
Dim response1 As WebResponse request.GetResponse()
        
Dim reader As StreamReader = New StreamReader(response1.GetResponseStream())
        
Dim str As String reader.ReadLine()

        
Response.Write(str
its write nothing...so i can grab it to loadhtml..
what could be the problem?
i think this is my last issue
Reply With Quote
  #9 (permalink)  
Old August 6th, 2011, 02:29 PM
Imar's Avatar
Wrox Author
Points: 72,022, Level: 100
Points: 72,022, Level: 100 Points: 72,022, Level: 100 Points: 72,022, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,076
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

ReadLine works for me with your code and returns the doc type. However, you probably want to use ReadToEnd to grab the full HTML. The following works for me and assigns str the meta tag. Notice I also added some Using statements to ensure objects are cleaned up.

Code:
Dim url As String = "http://www.youtube.com/watch?v=66rY3wHSneA"
Dim request As WebRequest = WebRequest.Create(url)
Using response As WebResponse = request.GetResponse()
  Using reader As StreamReader = New StreamReader(response.GetResponseStream())
    Dim result As String = reader.ReadToEnd()
    Dim doc As New HtmlDocument()
    doc.LoadHtml(result)
    Dim node As HtmlNode = doc.DocumentNode.SelectSingleNode("//meta[@name='description']")
    If node.ToString IsNot Nothing Then
      Dim str As String = node.GetAttributeValue("content", "")
    End If
  End Using
End Using
Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
nir987 (August 6th, 2011)
  #10 (permalink)  
Old August 6th, 2011, 02:39 PM
Authorized User
Points: 221, Level: 4
Points: 221, Level: 4 Points: 221, Level: 4 Points: 221, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2010
Posts: 55
Thanks: 9
Thanked 0 Times in 0 Posts
Default

thanks alot!!! your more than good book!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using meta tags amatytfc ASP.NET 2.0 Basics 1 August 6th, 2007 05:47 PM
meta tags ferlach HTML Code Clinic 5 June 5th, 2007 04:17 PM
META tags and master pages thenoseknows ASP.NET 2.0 Professional 1 October 9th, 2006 01:02 PM
MasterPages ContentPages and Meta tags michaelcode ASP.NET 2.0 Basics 5 June 1st, 2006 04:13 PM
Meta tags Adam H-W HTML Code Clinic 2 November 19th, 2003 11:25 AM



All times are GMT -4. The time now is 10:16 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.