更新时间:2022-06-24 10:09:54
您可以使用正则表达式从日志条目中读取信息.像这样:
You can read the information from the log entries with a regular expression. Something like this:
lines.each do |line|
matches = /^(\S+).*GET\s(.*)\sHTTP\S*\s(\d+)/.match(line)
ip = matches[1]
url = matches[2]
status = matches[3]
do
然后,您可以将该信息放入哈希中,并按自己的意愿进行处理.
Then you can put this information into a hash and process it how you like.