我在python中编写了一个Web服务器,客户端使用Web浏览器发送这样的请求:
http://localhost:13555/ChessBoard_x16_y16.bmp
在我打印客户端请求时,在服务器端,它是这样的:
GET /ChessBoard_x16_y16.bmp HTTP/1.1
Host: localhost:13555
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0
.8
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/43.0.2357.81 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8
GET /favicon.ico HTTP/1.1
Host: localhost:13555
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/43.0.2357.81 Safari/537.36
Accept: */*
Referer: http://localhost:13555/ChessBoard_x16_y16.bmp
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8
但我只想得到&打印实际的URL,如:
Referer: http://localhost:13555/ChessBoard_x16_y16.bmp
请告诉我该怎么做?
答案 0 :(得分:0)
在python中的结果集中进行常规的reg-ex搜索:
function child_support() {
add_theme_support('post-thumbnails', array('post', 'page', 'upcoming_events', 'directory_listings'));
}
add_action( 'after_setup_theme', 'child_support', 100 );
如果您没有注册:
import re
for line in <your results set>:
line = line.rstrip()
if re.search('^Referer:', line) :
print line