我如何使用经典的asp xmlhttp解析html描述元

问题描述 投票:0回答:2
html regex asp-classic regexp-like
2个回答
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

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
© www.soinside.com 2019 - 2024. All rights reserved.