How can I use urlparse to extract domain names from URLs in Python? or What's the best way to handle

14 Replies, 1659 Views

"Why is my urlparse output not splitting the URL correctly?"

Hey folks!

I’m trying to use urlparse to break down a URL, but it’s not splitting things the way I expected. Like, the netloc is empty or the path is weirdly merged with something else.

Here’s an example:
`urlparse("https://example.com/path?query=123")`
But sometimes it just... doesn’t work? Am I missing something obvious?

Also, does urlparse handle stuff like weird characters or missing schemes? Or do I need to preprocess the URL first?

Thanks in advance!

(PS: Python 3.10, if that matters.)

Messages In This Thread
How can I use urlparse to extract domain names from URLs in Python? or What's the best way to handle - by - 03-11-2024, 08:16 AM



Users browsing this thread: 1 Guest(s)