Created
June 4, 2018 18:10
-
-
Save vgmoose/c23658df453527056e8c9bd57fb7f152 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 urllib2 | |
import json | |
"""search for homebrew on either app store""" | |
def search(query): | |
response = urllib2.urlopen("http://switchbru.com/appstore/repo.json") | |
contents = str(response.read()) | |
packages = json.loads(contents)["packages"] | |
query = query.lower() | |
resp = [] | |
for package in packages: | |
if "title" in package and "description" in package and "details" in package: | |
if package["title"].find(query) > 0 or package["description"].find(query) > 0 or package["details"].find(query) > 0: | |
resp.append(package) | |
string = "\n".join([x["title"] + " https://switchbru.com/appstore/#/" + x["name"] for x in resp]) | |
print(string) | |
query = raw_input("Enter search query: ") | |
search(query) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment