如何从日志中提取由GET请求携带的HTTP响应状态码为200的gif文件?

huangapple 未分类评论49阅读模式
英文:

How can I extract the gif files requested by a GET request with Http response 200 from a log?

问题

livevideo.gif
count.gif
NASA-logo.gif
KSC-logosmall.gif

英文:

I have the next log file and I need to extract the gif files which were requested by a GET request and its status was 200.

unicomp6.unicomp.net ‐ ‐ [01/Jul/1995:00:00:06 ‐0400] "GET /shuttle/countdown/ HTTP/1.0" 200 3985
burger.letters.com ‐ ‐ [01/Jul/1995:00:00:11 ‐0400] "GET /shuttle/countdown/liftoff.html HTTP/1.0" 304 0
burger.letters.com ‐ ‐ [01/Jul/1995:00:00:12 ‐0400] "GET /images/NASA‐logosmall.gif HTTP/1.0" 304 0
burger.letters.com ‐ ‐ [01/Jul/1995:00:00:12 ‐0400] "GET/shuttle/countdown/video/livevideo.gif HTTP/1.0" 200 0
d104.aa.net ‐ ‐ [01/Jul/1995:00:00:13 ‐0400] "GET /shuttle/countdown/HTTP/1.0" 200 3985
unicomp6.unicomp.net ‐ ‐ [01/Jul/1995:00:00:14 ‐0400] "GET/shuttle/countdown/count.gif HTTP/1.0" 200 40310
unicomp6.unicomp.net ‐ ‐ [01/Jul/1995:00:00:14 ‐0400] "GET /images/NASA‐logosmall.gif HTTP/1.0" 200 786
unicomp6.unicomp.net ‐ ‐ [01/Jul/1995:00:00:14 ‐0400] "GET /images/KSC‐logosmall.gif HTTP/1.0" 200 1204
d104.aa.net ‐ ‐ [01/Jul/1995:00:00:15 ‐0400] "GET/shuttle/countdown/count.gif HTTP/1.0" 200 40310
d104.aa.net ‐ ‐ [01/Jul/1995:00:00:15 ‐0400] "GET /images/NASA‐logosmall.gif HTTP/1.0" 200 786

From the above example the response must be:

livevideo.gif
count.gif
NASA-logo.gif
KSC-logosmall.gif

As you can see in the response there are not duplicates, for example in the row 6 we have the count.gif record requested by a Get and with status 200, the same happens in the row 9 and in the response we have only one count.gif record.

答案1

得分: 0

尝试逐行读取文件,从每一行中提取文件名。这里可以使用正则表达式。

将gif文件名存储在一个Set中,以自动消除重复项。

英文:

Try reading the file one line at a time to extract the file name from each line. A regular expression would be useful here.

Store the gif file names in a Set to automatically eliminate the duplicates.

huangapple
  • 本文由 发表于 2020年5月2日 13:28:37
  • 转载请务必保留本文链接:https://java.coder-hub.com/61554905.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定