Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
re.search Q
#4
I am not sure how you come up with this string (and I suspect there is flaw in your approach), but

from urllib.parse import parse_qs
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'
print(parse_qs(request.splitlines()[-1]))
output

Output:
{'ssid': ['my_ssid'], 'password': ['my_pass'], 'ip': ['192.168.1.222'], 'gw': ['192.168.1.1'], 'sbnet': ['255.255.255.0'], 'dns': ['8.8.8.8']}
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
re.search Q - by ebolisa - Nov-30-2021, 11:12 AM
RE: re.search Q - by Gribouillis - Nov-30-2021, 11:19 AM
RE: re.search Q - by ebolisa - Nov-30-2021, 11:38 AM
RE: re.search Q - by buran - Nov-30-2021, 11:42 AM
re.search Q - by ebolisa - Nov-30-2021, 04:29 PM
RE: re.search Q - by bowlofred - Nov-30-2021, 04:37 PM
RE: re.search Q - by ebolisa - Nov-30-2021, 04:43 PM
RE: re.search Q - by bowlofred - Nov-30-2021, 05:33 PM
RE: re.search Q - by ebolisa - Nov-30-2021, 06:07 PM
RE: re.search Q - by Gribouillis - Nov-30-2021, 06:15 PM
RE: re.search Q - by ebolisa - Nov-30-2021, 06:21 PM
RE: re.search Q - by bowlofred - Nov-30-2021, 07:57 PM
RE: re.search Q - by ebolisa - Dec-01-2021, 01:18 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020