Spaces:
Running
Running
| import urllib.request, urllib.parse, json | |
| queries = [ | |
| '("ocr" OR "optical character recognition") in:name,description', | |
| '"ocr" OR "optical character recognition" in:name,description', | |
| 'ocr OR "optical character recognition"', | |
| 'ocr in:name,description' | |
| ] | |
| for q in queries: | |
| url = 'https://api.github.com/search/repositories?q=' + urllib.parse.quote(q) | |
| req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0', 'Accept':'application/vnd.github.v3+json'}) | |
| try: | |
| with urllib.request.urlopen(req) as r: | |
| data = json.loads(r.read()) | |
| print(f"Query: {q}") | |
| print(f"Count: {data['total_count']}\n") | |
| except Exception as e: | |
| print(f"Error on {q}: {e}") | |