Created
April 14, 2024 13:24
-
-
Save chapmanjacobd/d0aaff7b09d602b8fc6db8bc0c418e89 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse, re, webbrowser | |
from xklb.utils import web | |
def search_art(term): | |
search_url = f"https://artsandculture.google.com/search?q={term.replace(' ', '+')}" | |
response = web.requests_session().get(search_url) | |
if response.status_code == 200: | |
pattern = r"https://artsandculture.google.com/asset/[a-zA-Z0-9-_]+/[a-zA-Z0-9-_]+" | |
photo_urls = re.findall(pattern, response.text) | |
if photo_urls: | |
for url in photo_urls: | |
dezoomify_url = f"https://dezoomify.ophir.dev/#{url}" | |
print(f"Opening dezoomify for: {dezoomify_url}") | |
webbrowser.open(dezoomify_url) | |
else: | |
print("No photos found for this search term.") | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser( | |
description="Search art on artsandculture.google.com and load dezoomify for each photo." | |
) | |
parser.add_argument("term", nargs="+", help="Search term for art") | |
args = parser.parse_args() | |
search_art(" ".join(args.term)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment