url-validation

Validating URLs in Python

限于喜欢 提交于 2019-12-03 06:21:50
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 one known way to validate a URL, and it depends on what URLs you think you may need to validate. As well, I found it difficult to find an easy to read standard for URL structure. I did find the RFCs 3986 and 3987, but they contain much more than just how it is structured. Am I missing something, or is there no one standard way to validate a URL? bgschiller This looks like it might be a duplicate of How do you validate a URL

How can I check if a URL exists with Django’s validators?

蓝咒 提交于 2019-11-30 03:15:10
I want to check in django if a URL exists and if it does I want to show something on screen, i.e.: if URL_THAT_POINTS_TO_SOME_PDF exists SHOW_SOMETHING Bartek Edit: Please note, this is no longer valid for any version of Django above 1.5 I assume you want to check if the file actually exists, not if there is just an object (which is just a simple if statement) First, I will recommend always looking through Django's source code because you will find some great code that you could use :) I assume you want to do this within a template. There is no built-in template tag to validate a URL but you

Need a regex to validating a Url and support %20 and ()

那年仲夏 提交于 2019-11-29 02:38:26
I'm currently using the following regular expression to validation URLs: ^(?#Protocol)(?:(?:ht|f)tp(?:s?)\:\/\/|~\/|\/)?(?#Username:Password)(?:\w+:\w+@)? (?#Subdomains)(?:(?:[-\w]+\.)+(?#TopLevel Domains)(?:com|org|net|gov|mil|biz|edu|info|mobi|name|aero|jobs|museum|travel|[a-z]{2}))(?#Port)(?::[\d]{1,5})?(?#Directories)(?:(?:(?:\/(?:[-\w~!$+|.,=]|%[a-f\d]{2})+)+|\/)+|\?|#)?(?#Query)(?:(?:\?(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)(?:&(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)*)*(?#Anchor)(?:#(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)?$ I borrowed this

Need a regex to validating a Url and support %20 and ()

痞子三分冷 提交于 2019-11-27 16:58:38
问题 I'm currently using the following regular expression to validation URLs: ^(?#Protocol)(?:(?:ht|f)tp(?:s?)\:\/\/|~\/|\/)?(?#Username:Password)(?:\w+:\w+@)? (?#Subdomains)(?:(?:[-\w]+\.)+(?#TopLevel Domains)(?:com|org|net|gov|mil|biz|edu|info|mobi|name|aero|jobs|museum|travel|[a-z]{2}))(?#Port)(?::[\d]{1,5})?(?#Directories)(?:(?:(?:\/(?:[-\w~!$+|.,=]|%[a-f\d]{2})+)+|\/)+|\?|#)?(?#Query)(?:(?:\?(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)(?:&(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=

How to quickly check if URL server is available

眉间皱痕 提交于 2019-11-27 15:55:34
问题 I have a URL in the form http://www.mywebsite.com/util/conv?a=1&from=%s&to=%s And want to check if it is available. The links redirect me on a bad request page if I try to open these with a browser, however via code I can get the data that I need. Using a try-catch block on a HTTP request procedure is pretty slow, so I'm wondering how I could ping a similar address to check if its server is active. I have tried boolean reachable = InetAddress.getByName(myLink).isReachable(6000); But returns

How to check if URL is valid in Android

烂漫一生 提交于 2019-11-26 19:58:30
Is there a good way to avoid the "host is not resolved" error that crashes an app? Some sort of a way to try connecting to a host ( like a URL ) and see if it's even valid? Use URLUtil to validate the URL as below. URLUtil.isValidUrl(url) It will return True if URL is valid and false if URL is invalid . Pranav URLUtil.isValidUrl(url); If this doesn't work you can use: Patterns.WEB_URL.matcher(url).matches(); Wrap the operation in a try/catch. There are many ways that a URL can be well-formed but not retrievable. In addition, tests like seeing if the hostname exists doesn't guarantee anything

How to check if URL is valid in Android

浪子不回头ぞ 提交于 2019-11-26 06:33:02
问题 Is there a good way to avoid the \"host is not resolved\" error that crashes an app? Some sort of a way to try connecting to a host ( like a URL ) and see if it\'s even valid? 回答1: Use URLUtil to validate the URL as below. URLUtil.isValidUrl(url) It will return True if URL is valid and false if URL is invalid . 回答2: URLUtil.isValidUrl(url); If this doesn't work you can use: Patterns.WEB_URL.matcher(url).matches(); 回答3: I would use a combination of methods mentioned here and in other

C# How can I check if a URL exists/is valid?

我与影子孤独终老i 提交于 2019-11-26 03:18:04
问题 I am making a simple program in visual c# 2005 that looks up a stock symbol on Yahoo! Finance, downloads the historical data, and then plots the price history for the specified ticker symbol. I know the exact URL that I need to acquire the data, and if the user inputs an existing ticker symbol (or at least one with data on Yahoo! Finance) it works perfectly fine. However, I have a run-time error if the user makes up a ticker symbol, as the program tries to pull data from a non-existent web