fork download
  1. import re
  2.  
  3. sample_text = ['199.72.81.55 - - [01/Jul/1995:00:00:01 -0400] "GET /history/apollo/HTTP/1.0" 200 6245',
  4. 'unicomp6.unicomp.net - - [01/Jul/1995:00:00:06 -0400] "GET /shuttle/countdown/HTTP/1.0" 200 3985',
  5. '199.120.110.21 - - [01/Jul/1995:00:00:09 -0400] "GET /shuttle/missions/sts-73/mission-sts-73.html HTTP/1.0" 200 4085',
  6. 'burger.letters.com - - [01/Jul/1995:00:00:11 -0400] "GET /shuttle/countdown/liftoff.html HTTP/1.0" 304 0',
  7. '199.120.110.21 - - [01/Jul/1995:00:00:11 -0400] "GET /shuttle/missions/sts-73/sts-73-patch-small.gif HTTP/1.0" 200 4179']
  8.  
  9. def func():
  10. r = "\n".join(sample_text)
  11. regext = r'\bHTTP/\d\.\d"\s\d+\s(\d+)$'
  12. content_size = re.findall(regext, r, re.M)
  13. print(content_size)
  14.  
  15. func()
Success #stdin #stdout 0.02s 9592KB
stdin
Standard input is empty
stdout
['6245', '3985', '4085', '0', '4179']