我相信每个人都会呻吟,并告诉我查看文档(我有),但我只是不明白如何实现以下相同:
curl -s http://www.maxmind.com/app/locate_my_ip | awk '/align="center">/{getline;print}'
到目前为止,我在 python3 中的所有内容是:
import urllib.request
f = urllib.request.urlopen('http://www.maxmind.com/app/locate_my_ip')
for lines in f.readlines():
print(lines)
f.close()
说真的,任何建议(请不要告诉我阅读http://docs.python.org/release/3.0.1/library/html.parser.html,因为我已经学习python 1天了,很容易混淆) 一个简单的例子会很棒!!!