本帖最后由 柳之一 于 2013-8-9 17:24 编辑
rm端
module Wininet module_function def get_http_request(url) internetOpen = Win32API.new("wininet.dll","InternetOpen","plppl","l") internetOpenUrl = Win32API.new("wininet.dll","InternetOpenUrl","lppllp","l") internetReadFile = Win32API.new("wininet.dll","InternetReadFile","lplp","i") internetCloseHandle = Win32API.new("wininet.dll","InternetCloseHandle","l","l") buffer_size = 1024 return_buffer = '' session = internetOpen.call('RGSS Agent',1,nil,nil,0) file = internetOpenUrl.call(session,url,nil,0,0,0) loop do buf = ' ' * buffer_size n = 0 out = [n].pack('i!') result = internetReadFile.call(file,buf,buffer_size,out) n = out.unpack('i!')[0] if result and n == 0 break end return_buffer += buf[0,n] end internetCloseHandle.call(file) internetCloseHandle.call(session) return return_buffer end end
module Wininet
module_function
def get_http_request(url)
internetOpen = Win32API.new("wininet.dll","InternetOpen","plppl","l")
internetOpenUrl = Win32API.new("wininet.dll","InternetOpenUrl","lppllp","l")
internetReadFile = Win32API.new("wininet.dll","InternetReadFile","lplp","i")
internetCloseHandle = Win32API.new("wininet.dll","InternetCloseHandle","l","l")
buffer_size = 1024
return_buffer = ''
session = internetOpen.call('RGSS Agent',1,nil,nil,0)
file = internetOpenUrl.call(session,url,nil,0,0,0)
loop do
buf = ' ' * buffer_size
n = 0
out = [n].pack('i!')
result = internetReadFile.call(file,buf,buffer_size,out)
n = out.unpack('i!')[0]
if result and n == 0
break
end
return_buffer += buf[0,n]
end
internetCloseHandle.call(file)
internetCloseHandle.call(session)
return return_buffer
end
end
服務端time.php
<?php echo "<time>".date("Y-m-d")."</time>"; ?>
<?php
echo "<time>".date("Y-m-d")."</time>";
?>
url = ''http://www.xxx.com/time.php'
page = Wininet.get_http_request(url)
if page =~ /<time>(.*)<\/time>/i
p $1
end |