Skip to content

Instantly share code, notes, and snippets.

@vgmoose
Created June 4, 2018 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vgmoose/c23658df453527056e8c9bd57fb7f152 to your computer and use it in GitHub Desktop.
Save vgmoose/c23658df453527056e8c9bd57fb7f152 to your computer and use it in GitHub Desktop.
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