赞 | 0 |
VIP | 12 |
好人卡 | 42 |
积分 | 7 |
经验 | 44348 |
最后登录 | 2024-4-1 |
在线时间 | 791 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 687
- 在线时间
- 791 小时
- 注册时间
- 2011-10-20
- 帖子
- 2394
|
本帖最后由 end55rpg 于 2013-8-3 07:52 编辑
亿万星辰 发表于 2013-8-2 23:06
那说了半天Get_Http_Info.get_html是什么内容啊,你还是不说……
用 wb 来写
bitmap = Get_Version_Info.get_version("http://uc.66rpg.com/data/avatar/000/24/98/90_avatar_middle.jpg")
f = File.open("temp.jpg", "wb")
f.write(bitmap)
f.close
= =我试了下运行这个怎么不管用额,下载的temp.jpg还是无法显示。。。你测试能显示?
gethtml如下↓。。
#================================================== # 本脚本来自 [url]www.66rpg.com[/url] 使用和转载请保留此信息 #================================================== class Get_Http_Info AGENT = "RGSS PLAYER" INTERNET_OPEN_TYPE_PRECONFIG = 0 # IEの設定を仕様 INTERNET_OPEN_TYPE_DIRECT = 1 # プロキシを使用しない def Get_Http_Info.InternetOpen() io = Win32API.new('wininet', 'InternetOpen', %(p, l, p, p, l), 'l') hInternet = io.call(AGENT, INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0) return hInternet end def Get_Http_Info.InternetOpenUrl(hSession, url) iou = Win32API.new('wininet', 'InternetOpenUrl', %(l, p, p, l, l, l), 'l') hService = iou.call(hSession, url, nil, 0, 0, 0) return hService end def Get_Http_Info.InternetReadFile(hService,length,bk) content = "" read_size = 1024 # 一次读入文件的尺寸 irf = Win32API.new('wininet', 'InternetReadFile', %(l, p, i, p), 'i') bk.call(0,length) id=0 while(true) buf = "\0" * read_size red = [0].pack('L') irf.call( hService, buf, read_size, red ) bk.call(id*read_size,length) id+=1 # 读到文件末端 break if (red.unpack('L') == [0]) buf.delete!("\0") content += buf end return content end HTTP_QUERY_STATUS_CODE = 19 CONTENT_LENGTH=5 def Get_Http_Info.HttpQueryInfo(hService) read_size = 1024 buf = "\0" * read_size red = [read_size-1].pack('L') hqi = Win32API.new('wininet', 'HttpQueryInfo', %(l, l, p, p, p), 'i') isOk = hqi.call( hService, HTTP_QUERY_STATUS_CODE, buf, red, nil) buf.delete!("\0") return buf end def Get_Http_Info.InternetCloseHandle(hInternet) ich = Win32API.new('winInet', 'InternetCloseHandle', %(l), 'i') isOk = ich.call(hInternet) return isOk end HTTP_CODE_OK = "200" def Get_Http_Info.HttpQuerySize(hService) read_size = 1024 buf = "\0" * read_size red = [read_size-1].pack('L') hqi = Win32API.new('wininet', 'HttpQueryInfo', %(l, l, p, p, p), 'i') isOk = hqi.call( hService, CONTENT_LENGTH, buf, red, nil) buf.delete!("\0") return buf end def Get_Http_Info.get_info(url) info = nil begin hInternet = InternetOpen() if (hInternet != 0) hService = InternetOpenUrl(hInternet, url) if (hService != 0) status_code = HttpQueryInfo(hService) if (status_code == HTTP_CODE_OK) info = InternetReadFile(hService) end InternetCloseHandle(hService) end InternetCloseHandle(hInternet) end rescue # 例外发生 return nil end ary = [] info.each_line do |line| next if line.empty? ary.push line end return ary[271].scan(/\w+<\/a>/) end def Get_Http_Info.get_html(url,bk) info = nil # begin hInternet = InternetOpen() if (hInternet != 0) hService = InternetOpenUrl(hInternet, url) if (hService != 0) status_code = HttpQueryInfo(hService) length=HttpQuerySize(hService).to_i if (status_code == HTTP_CODE_OK) #a=File.open(pathname,"wb") info = InternetReadFile(hService,length,bk) end InternetCloseHandle(hService) end InternetCloseHandle(hInternet) end #rescue # 例外发生 # return nil #end return info end end
#==================================================
# 本脚本来自 [url]www.66rpg.com[/url] 使用和转载请保留此信息
#==================================================
class Get_Http_Info
AGENT = "RGSS PLAYER"
INTERNET_OPEN_TYPE_PRECONFIG = 0 # IEの設定を仕様
INTERNET_OPEN_TYPE_DIRECT = 1 # プロキシを使用しない
def Get_Http_Info.InternetOpen()
io = Win32API.new('wininet', 'InternetOpen', %(p, l, p, p, l), 'l')
hInternet = io.call(AGENT, INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0)
return hInternet
end
def Get_Http_Info.InternetOpenUrl(hSession, url)
iou = Win32API.new('wininet', 'InternetOpenUrl', %(l, p, p, l, l, l), 'l')
hService = iou.call(hSession, url, nil, 0, 0, 0)
return hService
end
def Get_Http_Info.InternetReadFile(hService,length,bk)
content = ""
read_size = 1024 # 一次读入文件的尺寸
irf = Win32API.new('wininet', 'InternetReadFile', %(l, p, i, p), 'i')
bk.call(0,length)
id=0
while(true)
buf = "\0" * read_size
red = [0].pack('L')
irf.call( hService, buf, read_size, red )
bk.call(id*read_size,length)
id+=1
# 读到文件末端
break if (red.unpack('L') == [0])
buf.delete!("\0")
content += buf
end
return content
end
HTTP_QUERY_STATUS_CODE = 19
CONTENT_LENGTH=5
def Get_Http_Info.HttpQueryInfo(hService)
read_size = 1024
buf = "\0" * read_size
red = [read_size-1].pack('L')
hqi = Win32API.new('wininet', 'HttpQueryInfo', %(l, l, p, p, p), 'i')
isOk = hqi.call( hService, HTTP_QUERY_STATUS_CODE, buf, red, nil)
buf.delete!("\0")
return buf
end
def Get_Http_Info.InternetCloseHandle(hInternet)
ich = Win32API.new('winInet', 'InternetCloseHandle', %(l), 'i')
isOk = ich.call(hInternet)
return isOk
end
HTTP_CODE_OK = "200"
def Get_Http_Info.HttpQuerySize(hService)
read_size = 1024
buf = "\0" * read_size
red = [read_size-1].pack('L')
hqi = Win32API.new('wininet', 'HttpQueryInfo', %(l, l, p, p, p), 'i')
isOk = hqi.call( hService, CONTENT_LENGTH, buf, red, nil)
buf.delete!("\0")
return buf
end
def Get_Http_Info.get_info(url)
info = nil
begin
hInternet = InternetOpen()
if (hInternet != 0)
hService = InternetOpenUrl(hInternet, url)
if (hService != 0)
status_code = HttpQueryInfo(hService)
if (status_code == HTTP_CODE_OK)
info = InternetReadFile(hService)
end
InternetCloseHandle(hService)
end
InternetCloseHandle(hInternet)
end
rescue
# 例外发生
return nil
end
ary = []
info.each_line do |line|
next if line.empty?
ary.push line
end
return ary[271].scan(/\w+<\/a>/)
end
def Get_Http_Info.get_html(url,bk)
info = nil
# begin
hInternet = InternetOpen()
if (hInternet != 0)
hService = InternetOpenUrl(hInternet, url)
if (hService != 0)
status_code = HttpQueryInfo(hService)
length=HttpQuerySize(hService).to_i
if (status_code == HTTP_CODE_OK)
#a=File.open(pathname,"wb")
info = InternetReadFile(hService,length,bk)
end
InternetCloseHandle(hService)
end
InternetCloseHandle(hInternet)
end
#rescue
# 例外发生
# return nil
#end
return info
end
end
|
|