I don't understand the use of python re library.

not long after I first came into contact with python, I needed to use regularities when crawling pages, but I was confused after reading python"s re library for a long time. Maybe I got silly after a whole day"s work. =-sharp
I have many of the following url characters that need to be regularly fetched & the numbers after pn
http://www.qqddc.com/proIndex.do?method=index&thin=0&pb=168&pn=10
also need to use regularities to get the following characters in addition to
http://www.qqddc.com/proIndex.do?method=index&thin=0&pb=168&pn=
, a string of characters such as
ask for instructions here. Thank you for your guidance. Thank you


it is not recommended to use regularization, but it is recommended to use the standard urllib library to complete

.
>>>import urllib
>>>a = urllib.parse.parse_qs(urllib.parse.urlparse("http://abc.com/def?x=2&pn=2").query)
>>>a
{'x': ['2'], 'pn': ['2']}

or get dict directly in the following way

>>>a = dict(urllib.parse.parse_qsl(urllib.parse.urlparse("http://abc.com/def?x=2&pn=2").query))
>>>a
{'x': '2', 'pn': '2'}
Menu