我正在寻找相当于_grep -B14 MMA
我有一个打开的 URL,它会吐出很多行。我想要
- 找到具有“MMa”的行
- 然后打印它之前的第 14 行
我什至不知道从哪里开始。
import urllib
import urllib2
url = "https://longannoyingurl.com"
opts = {
'action': 'Dump+It'
}
data = urllib.urlencode(opts)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
print response.read() # gives the full html output