Advertisement
Link712011

net

Aug 20th, 2017
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.69 KB | None | 0 0
  1. local internet = require('internet')
  2. local net = {}
  3.  
  4. local function get_page_to_file(url, filepath)
  5.     local file
  6.     local conn
  7.     local tmp = {}
  8.  
  9.     tmp['headers'] = {}
  10.     tmp['headers']['Pragma'] = 'no-cache'
  11.     tmp['headers']['Cache-Control'] = 'no-cache, no-store, must-revalidate'
  12.     tmp['headers']['Expires'] = '0'
  13.     file = io.open(filepath, 'w')
  14.     if not file then
  15.         return false
  16.     end
  17.     conn = internet.request(url, tmp, tmp['headers'])
  18.     if not conn then
  19.         file:close()
  20.         return false
  21.     end
  22.     for char in conn do
  23.         file:write(char)
  24.     end
  25.     file:close()
  26.     return true
  27. end
  28. net.get_page_to_file = get_page_to_file
  29.  
  30. return net
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement