웹페이지를 크롤링합니다. 때로는 실제 업데이트된 일기예보를 달성하는 것이 필요합니다. XMLHTTP 구성 요소는 웹 페이지의 지정된 부분을 캡처하는 데 사용됩니다.
HTML 소스 코드를 분할해야 함
이 예제에서 캡처한 html 소스 코드는 다음과 같습니다.
<p align=left>2004년 8월 24일 화요일, 낮: 맑음, 때때로 흐림, 운남 풍속 3-4, 밤: 맑음 남풍 3-4 온도: 최고 29℃, 최저 19℃ </p>
프로그램은 다음과 같습니다.
종료일까지 2004년 8월 24일을 키워드 검색으로 사용</p>
촬영 내용은 2004년 8월 24일 화요일입니다. 낮: 맑음, 때때로 흐림, 운남 바람 수준 3-4, 밤: 맑은 남풍 수준 3-4, 최대 29℃, 최소 19℃
깨끗해요. 녹음하세요.
<%
오류 발생 시 다음 재개
Server.ScriptTimeOut=9999999
함수 getHTTPage(경로)
t = GetBody(경로)
getHTTPPage=BytesToBstr(t,GB2312)
기능 종료
함수 GetBody(url)
오류 발생 시 다음 재개
검색 설정 = CreateObject(Microsoft.XMLHTTP)
검색 포함
.Open Get, url, False, ,
.보내다
GetBody = .ResponseBody
끝
검색 설정 = 없음
기능 종료
함수 BytesToBstr(body,Cset)
희미한 객체 스트림
objstream = Server.CreateObject(adodb.stream) 설정
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write 본문
objstream.위치 = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
objstream = 아무것도 설정하지 않음
기능 종료
함수 Newstring(wstr,strng)
Newstring=Instr(lcase(wstr),lcase(strng))
Newstring<=0이면 Newstring=Len(wstr)
기능 종료
%>
<html>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 MARGINHEIGHT=0 MARGINWIDTH=0>
<!-- 시작-->
<%
희미한 wstr,str,url,start,over,dtime
dtime=연도(날짜)&연도&월(날짜)&월&일(날짜)&일
URL=http://www.vevb.com/
wstr=getHTTPPage(url)
시작=Newstring(wstr,dtime)
over=Newstring(wstr,</p>)
body=mid(wstr,start,over-start)
response.write <MARQUEE onmouseover=this.stop(); onmouseout=this.start();>&body&</marquee>
%>
<!--끝-->
</body></html>