How to use the urlsplit () method of python crawler
This article mainly introduces how to use the urlsplit () method of python crawler. It is very detailed and has certain reference value. Friends who are interested must finish it!
1. Very similar to the urlparse () method, but it no longer parses the params part separately and returns only five results.
From urllib.parse import urlsplit result = urlsplit ('http://www.baidu.com/index.html;user?id=5#comment')print(result)
The results are as follows:
SplitResult (scheme='http', netloc='www.baidu.com', path='/index.html;user', query='id=5', fragment='comment')
As you can see, the returned result is SplitResult.
2. In fact, it is also a tuple type, which can be obtained either by attribute or index.
From urllib.parse import urlsplit result = urlsplit ('http://www.baidu.com/index.html;user?id=5#comment')print(result.scheme, result [0]) these are all the contents of the article "how to use the python crawler urlsplit () method". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!