0
我想只提取在的Python IP地址和URL
153.12.123.123 - - [13/Nov/2014:15:06:43 -0700] "GET /icons/AHPS/0.06.png HTTP/1.1" 123 1234 "http://198.123.123.123/index.html" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/1234567 Firefox/33.0"
153.12.123.123 - - [13/Nov/2014:15:06:43 -0700] "GET /icons/AHPS/0.06.png HTTP/1.1" 123 1234 "http://abc.weatherabc.org/?Center=38.123456789" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/1234556 Firefox/33.0"
我目前使用命令行上此表達式的格式包含數據的記錄的IP地址和URL部分正則表達式:
[^\"]*\"[^\"]*\"[^\"]*\"([^\"]*)\"
和它產生的這些作爲結果:
http://198.123.123.123/index.html
http://abc.weatherabc.org/?Center=38.123456789
但是我想REGUL AR表達產生僅這些部分:
http://198.123.123.123/
http://abc.weatherabc.org/
或
http://198.123.123.123
http://abc.weatherabc.org
請幫助。提前致謝!
所以,你的問題其實是關於從URL中取出部件? –
你不能用這個嗎? 'http:\/\/[0-9a-zA-z \。] +' – David
'(?<= \「)http [^ \」] +(?= /)'? [鏈接](https://regex101.com/r/YsqivJ/1) – Gurman