GET /ecx/ HTTP/1.1
Host: test.baidu.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Cookie: __utma=89925662.1398539168.1423185721.1423185721.1423185721.1; __utmz=89925662.1423185721.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
Connection: keep-alive
求个正则匹配 GET或者POST后面的地址(例如/ecx/)和Host后面的地址(例如test.baidu.com)
谢
1
lapertem4 OP s = re.findall(r'^(POST|GET)(.*)HTTP',cont,re.M)
q = re.findall(r'^Host:(.*)',cont,re.M) if s and q: print s[0][1].strip() print q[0].strip() |