Nov-30-2021, 11:12 AM
Hi,
I'm trying to extract info from a web form (request) but I get the error shown below.
I know group() exists so, I cannot understand the error.
TIA
I'm trying to extract info from a web form (request) but I get the error shown below.
I know group() exists so, I cannot understand the error.
TIA
import re request = 'POST /configure HTTP/1.1\r\nHost: 192.168.4.1\r\nOrigin: http://192.168.4.1\r\nContent-Type: application/x-www-form-urlencoded\r\nAccept-Encoding: gzip, deflate\r\nConnection: keep-alive\r\nUpgrade-Insecure-Requests: 1\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nUser-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 15_1_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.1 Mobile/15E148 Safari/604.1\r\nReferer: http://192.168.4.1/\r\nContent-Length: 108\r\nAccept-Language: en-GB,en;q=0.9\r\n\r\nssid=my_ssid&password=my_pass&token=&ip=192.168.1.222&gw=192.168.1.1&sbnet=255.255.255.0&dns=8.8.8.8' match = re.search("ssid=([^&]*)&password=(.*)&token=(.*)&ip=(.*)&sbnet=(.*)&gw=(.*)&dns=(.*)", request) ip = match.group(4) print('ip', ip)
Output:Traceback (most recent call last):
File "C:\SharedFiles\Python\practice\test.py", line 4, in <module>
ip = match.group(4)
AttributeError: 'NoneType' object has no attribute 'group'