-
'ชื่อ: ฟังก์ชั่นคอลเลกชันทั่วไปของ ASP ผู้ที่ต้องการแก้ไขเวอร์ชันคุณภาพสูงเอง
'ผู้แต่ง: Liu Yongfa
วันที่: 2007-6-23
FunctionGetHttppage (เส้นทาง)
t = getBody (เส้นทาง)
gethttppage = bytestobstr (t, "GB2312")
endfunction
FunctionGetBody (URL)
onerrorresumenext
setxmlhttp = createObject ("microsoft.xmlhttp"))
withxmlhttp
.Open "Get", url, false, "", ""
.ส่ง
. WaitForResponse1000
getBody = .ResponseBody
จบลงด้วย
setxmlhttp = ไม่มีอะไร
endfunction
FunctionByTestobstr (Body, CSET)
onerrorresumenext
dimobjstream
setObjstream = server.createObject ("adodb.stream")
objstream.type = 1
objstream.mode = 3
objstream.open
objstream.writebody
objstream.position = 0
objstream.type = 2
objstream.charset = cset
bytestobstr = objstream.readText
objstream.close
setObjstream = ไม่มีอะไร
endfunction
FunctionGetHttpimg (URL)
onerrorresumenext
dimxmlhttp
setxmlhttp = server.createObject ("msxml2.xmlhttp")))
xmlhttp.open "get", url, false
xmlhttp.send ()
ifxmlhttp.status <> 200thenexitfunction
gethttpimg = xmlhttp.responsebody
setxmlhttp = ไม่มีอะไร
iferr.number <> 0thenerr.Clear
endfunction
functionsave2local (จาก, tofile)
Dimgeturl, Objstream, IMGS
getUrl = trim (จาก)
imgs = gethttpimg (geturl)
setObjstream = server.createObject ("adodb.stream")
objstream.type = 1
objstream.open
objstream.writeimgs
objstream.savetofiletofile, 2