-
Notifications
You must be signed in to change notification settings - Fork 169
Closed as not planned
Labels
enhancementIssue/PR: A new featureIssue/PR: A new featureoutdatedIssue/PR: Open for more than 3 monthsIssue/PR: Open for more than 3 months
Description
I have a feature request: validate a URL if it's an image or not.
Rationale: I'm writing a scraper that extracts all links. From this list I want to filter out just the image links. I think it could be done simply by analyzing the URL string: if it contains .jpg or .png or .gif then it's an image.
Edit: here is my current solution
IMAGE_EXTENSIONS = ['jpg', 'jpeg', 'png', 'gif'] # can be extended
def is_image(path):
"""
Path can be a URL or a local file. Decide if it's an image or not.
"""
path = path.lower()
for x in IMAGE_EXTENSIONS:
if x in path:
return True
#
return False
Metadata
Metadata
Assignees
Labels
enhancementIssue/PR: A new featureIssue/PR: A new featureoutdatedIssue/PR: Open for more than 3 monthsIssue/PR: Open for more than 3 months