我的代码:
#Importing the urllib tool to my program
import urllib.request
#Fetch data from URL
response = urllib.request.urlopen('<URL>')
#Store that response into the variable below
taginfo = response.read()
#Tag info result of search for SSI values
taginforesult = taginfo
#print taginfo
print(taginfo)
以上在 Python Shell 中的结果是正确的,如下所示:
b'LOCATE00016331: tagid="00016331", taggroupid=LOCATE, tagtype=mantis04A, irlocator=null, motion=false, tamper=false, panic=false, lowbattery=false, locationzone="", gpsid="", lastgpsid="", lastgpsts=null, confidencebyrule={}\r\n(CarrierHQ_channel_A: reader=CarrierHQ, channel="A", ssi=-95)\r\n(CarrierHQ_channel_B: reader=CarrierHQ, channel="B", ssi=-99)\r\n\r\n\r\n'
我想知道的是:如何从上面的响应中只选择SSI=-95
andSSI-99
值,然后将它们插入到SSI-A
andSSI-B
变量中?
我strip()
,,,,findall()
... search()
?