我有一个日志文件,其中包含如下行。
10.10.205.100 100.10.56.5 - [23/Oct/2012:15:30:01 +0000] "GET /way/?cb=777:Obj.Status&log=signing_in_service&cache=1350334642666 HTTP/1.1" 200 53 "https://www.sample.com/signin?off=undefined&questions=&nouser=&link=%23&country=origin&displayLayer=" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2" "PD_STATEFUL_d64f218a-fa6a-11e0-b7df-623c1eeb9903=%2Fgateway; PD-ERR=0x132120c8; PD-HOST=sample.com; PD-REFERER=https://www.sample.com/profile%3Fundefined%3D; PD-REFPAGE=signin_user; pSite=; __SIGNIN=signin%23cw%3D400%3Ach%3D321; mmcore.pd=916254201%7CAgAAAAoBQvp/zPBKCBGRP6QBAOZMgV9Kf89IAAsAAAAtzSlGSn/PSAAAAAD/////AEoIAQAAAAAAAQAAAAAA////////////////AAAAAAABRQ%3D%3D; mmcore.srv=cg4.use; mmid=-1116944464%7CAgAAAAr6f8zwSggAAA%3D%3D; mmcore.tst=0.155; PD-SGNPAGE=http%3A%2F%2Fwww.sample.com%2Fcommon%2Fregister%2Feproxy.html; UnicaNIODID=A3nRYVRjMyy-Xv66UJt; survey=1350334587161"
我正在尝试获取上一行中为 200 的 http 状态代码。这将放在字符串 HTTP/1.1" 之后。http 的版本(这里是 1.1)可能并非在所有行中都通用。
根据状态码(如果不是 200 和其他少数状态),我必须连同日志文件一起发送一封电子邮件。