Created
February 13, 2014 23:39
-
-
Save loisaidasam/8986313 to your computer and use it in GitHub Desktop.
Android Scraper - get info about an app in the Google Play Store
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 | |
import sys | |
from bs4 import BeautifulSoup | |
import requests | |
def main(): | |
parser = argparse.ArgumentParser(description="Get info about an app in the Google Play Store") | |
parser.add_argument('-v', '--version', action='store_true') | |
parser.add_argument('url', help="URL (or namespaced id, like com.example.appname) of the app you want details about") | |
args = parser.parse_args() | |
url = args.url | |
if not url.startswith('http'): | |
url = "https://play.google.com/store/apps/details?id=%s" % url | |
response = requests.get(url) | |
if response.status_code != 200: | |
print >> sys.stderr, "Bad status code: %s" % response.status_code | |
return | |
if args.version: | |
soup = BeautifulSoup(response.content) | |
div = soup.find(itemprop="softwareVersion") | |
print div.string | |
return | |
print "OK" | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment