Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Does anyone know how to read META tag values?

Status
Not open for further replies.

yogi77

Programmer
Oct 12, 2001
25
0
0
GB
Hi,
Can anyone help me? I am using query string to pass parameters, from a page called getlist.asp, to an .asp page, something like this;


I get a page of html returned something like this;

<HTML>
<HEAD>
<TITLE>Page for electronic post-processing</TITLE>
<META NAME=&quot;Total&quot; Content=&quot;2&quot;>
<META NAME=&quot;WO&quot; Content=&quot;WO123&quot;>
<META NAME=&quot;Status&quot; Content=&quot;Opened&quot;>
<META NAME=&quot;WO&quot; Content=&quot;WOB456&quot;>
<META NAME=&quot;Status&quot; Content=&quot;Accepted&quot;>
</HEAD>
</HTML>

It is worth pointing out that I don't have direct access to the query.asp, it's a 3rd party site that I just make reference to it as shown above.

Can someone tell me how I can read these values back out of the page, i.e. the meta tag names and content?

I know I could do something like this;

total=document.all(&quot;total&quot;).content

but I can't do that if I don't have direct access to the code in query.asp? Can I get these values from my getlist.asp?

Confused...any help would be great.
 
Hi Yogi77,

I'm not really that clear on what you are trying to do but I thought this might be helpful. You can use the XMLHTTP object to retrieve the full page source from any online page. Use the following function:

Code:
Function GetHTML(strPage)
    
Dim objXMLHttp
   
On Error Resume Next
    
Set objXMLHttp = Server.CreateObject (&quot;Microsoft.XMLHTTP&quot;)
objXMLHttp.Open &quot;GET&quot;, strPage ,False,&quot;&quot;,&quot;&quot;
objXMLHttp.Send
    
If Err.Number = 0 Then
  If objXMLHttp.Status = 200 then
      GetHTML = objXMLHttp.ResponseText
  Else
      Response.Write(&quot;no page found&quot;)
      GetHTML = &quot;Incorrect URL&quot;
  End if
        
Else
  GetHTML = Err.Description
End If
    
Set objXMLHttp = Nothing 

End Function

To call the function use:

Code:
newPage = GetHTML(strPage)

Then response.Write the new variable to see the resulting code on the screen. I'm not that familiar with this but it might be useful???!!!
 
Nice use of XMLHTTP. This is probably what your going to need to do as META tags are designed to be read and parsed by a remote server. Once you have the page source in your newPage string above you will be able to parse it out to get the values of the META tags. You will most likely want to use combinations of the InStr function and mid function, and if the number of meta tags will always be a constant and the names will always be the same than you could set up variables to hold the content, otherwise you may want a three dimensional array to hold the variable name and the value from each of the tags.
Not undermining the previous post, just trying to elaborate on what he was thinking :)
-Tarwn &quot;Customer Support is an art not a service&quot; - marketing saying
&quot;So are most other forms of torture&quot; - programmers response
(The Wiz Biz - Rick Cook)
 
Thank you both emblewembl and Tarwn, this sounds like something I need to go and explore, looks promising though :) ...

I'll let you know how I get on.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top