1

i have using classic code with parse html desctiption meta is:

Html exaple:

<meta name="keywords" content="Software AG, Altenkesseler Straße 17, Saarbrücken, Saarland, software ag, Ofis"  />

Parse Code:

    Baslangic = InStr(1,sdata,"<meta name=" & Chr(34) & "keywords" & Chr(34), 1) + Len("<meta name=" & Chr(34) & "keywords" & Chr(34)) 
    Baslangic = InStr(Baslangic,sdata,Chr(34),1)+1 
    Genislik = InStr(Baslangic,sdata,Chr(34),1) - Baslangic

KeywordAl= Mid(sdata, Baslangic, Genislik) 

this is work but when the html code change location of writings for example:

<meta  content="Software AG, Altenkesseler Straße 17, Saarbrücken, Saarland, software ag, Ofis" name="keywords" />

it doesnt work my code. Is there a way to run on both sides? regex or on my way.

thank you

4

2 回答 2

0

你可以尝试这样的事情:

meta = "<meta name=""keywords"" content=""Software AG, Altenkesseler Straße 17, Saarbrücken, Saarland, software ag, Ofis""  />"
if InStr( meta, "content=" ) > 0 then
    arrMeta = Split( meta, "content=" )
    keywords = arrMeta( 1 )       ''-- your data will be in the 2nd row of the array
    keywords = Trim( Replace( Replace( Replace( keywords, """", "" ), "/>", "" ), "name=keywords", "" ) )
end if

Response.Write keywords
于 2017-06-28T14:50:55.123 回答
0
if (instr(1, sdata,"<meta ", 1)=1 and instr(7, sdata, "name=""keywords""", 1)>6) then
  Set regEx = New RegExp
  regEx.Pattern = "content=""(.+?)"""   
  regEx.IgnoreCase = True
  Set matches = regEx.Execute(sdata)
  if matches.Count > 0 then
    KeywordAl = matches(0).SubMatches(0)
  end if
end if
于 2017-06-28T07:27:04.677 回答