일부 원격 콘텐츠를로드 중이므로 regex를 사용하여 일부 태그의 내용을 격리해야합니다.기본 ASP에서 regex를 사용하여 특정 요소의 내용을 가져옴
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "GET", url, false
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.setRequestHeader "Accept-Language", "en-us"
xmlhttp.send "x=hello"
status = xmlhttp.status
if err.number <> 0 or status <> 200 then
if status = 404 then
Response.Write "[EFERROR]Page does not exist (404)."
elseif status >= 401 and status < 402 then
Response.Write "[EFERROR]Access denied (401)."
elseif status >= 500 and status <= 600 then
Response.Write "[EFERROR]500 Internal Server Error on remote site."
else
Response.write "[EFERROR]Server is down or does not exist."
end if
else
data = xmlhttp.responseText
나는 기본적으로 또한 <title>Here is the title</title>
메타 설명, 키워드 및 일부의 오픈 그래프 메타 데이터의 내용을 얻을 필요가있다.
그리고 마지막으로 내가의 콘텐츠를 필요가 첫<h1>Heading</h1>
및 <p>Paragraph</p>
가 어떻게이 일을 얻을 수있는 HTML 데이터를 분석 할 수 있습니까? 정규식을 사용해야합니까?
xml 파서 대신 사용 하시겠습니까? –
반환 된 내용을 XML로 구체화하고 노드 선택을 사용할 수 있습니까? 그게 어떻게 효과가 있을지 자세히 설명해 주시겠습니까? 감사합니다 @ DanielA.White –