赞 | 0 |
VIP | 15 |
好人卡 | 21 |
积分 | 7 |
经验 | 24727 |
最后登录 | 2021-10-29 |
在线时间 | 2184 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 672
- 在线时间
- 2184 小时
- 注册时间
- 2009-12-6
- 帖子
- 607
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
嗯,看了脚本不晕再继续。- 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)
- content = ""
- read_size = 1024 # 一次读入文件的尺寸
- irf = Win32API.new('wininet', 'InternetReadFile', %(l, p, i, p), 'i')
- while(true)
- buf = "\0" * read_size
- red = [0].pack('L')
- irf.call( hService, buf, read_size, red )
- if(red.unpack('L') == [0])
- #读到文件末端
- break
- end
- buf.delete!("\0")
- content += buf
- end
- return content
- end
- HTTP_QUERY_STATUS_CODE = 19
-
- 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.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
- end
复制代码 不知道以前在哪找到的这个,打开网络文件,现在很想用,请问应该怎样 |
|