Advertisement
Guest User

Untitled

a guest
Apr 13th, 2013
13,849
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. import zlib
  2.  
  3. BEFORE = '''\
  4. G-Method:GET
  5. G-Url:https://plus.google.com/u/0/
  6. User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1470.0 Safari/537.36
  7. Referer:https://www.google.com/
  8. Cookie:PREF=ID=c466dedd9499308f:U=4d6ba2ae810e18e8:FF=0:LD=zh-CN:NW=1:CR=2:
  9. Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  10. Accept-Language:zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4
  11. Accept-Encoding:gzip,deflate,sdch
  12. Host:plus.google.com
  13. Connection:close
  14. '''
  15.  
  16. AFTER = '''\
  17. G-Method:GET
  18. G-Url:https://plus.google.com/u/0/
  19. User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1470.0 Safari/537.36
  20. Referer:http://www.google.com/
  21. Cookie:PREF=ID=c466dedd9499308f:U=4d6ba2ae810e18e8:FF=0:LD=zh-CN:NW=1:CR=2:
  22. G-Abbv:AL,AE,A
  23. '''
  24.  
  25. deflate = lambda x:zlib.compress(x)[2:-4]
  26. rate = lambda a,b: '%g%%' % round(100.0*abs(a-b)/max(a,b), 2)
  27. print 'uncompressed rate:', (len(B), len(A), rate(len(B), len(A)))
  28. print 'compressed rate:', (len(deflate(B)), len(deflate(A)), rate(len(deflate(B)),len(deflate(A))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement