Validating URLs in Python

前端 未结 5 675
广开言路
广开言路 2020-12-15 06:43

I\'ve been trying to figure out what the best way to validate a URL is (specifically in Python) but haven\'t really been able to find an answer. It seems like there isn\'t o

5条回答
  •  长情又很酷
    2020-12-15 06:57

    I would use the validators package. Here is the link to the documentation and installation instructions.

    It is just as simple as

    import validators
    url = 'YOUR URL'
    validators.url(url)
    

    It will return true if it is, and false if not.

提交回复
热议问题