title: Creating a python web scraper to get metadata for google play store apps
body: <p>I am very new to Python and am really interested in learning more. I have been given a task by a course I am doing currently...</p>
  
  <ul>
  <li>Please write a small Python script that crawls the Google Play web store (<a href="https://play.google.com/store" rel="nofollow noreferrer">https://play.google.com/store</a>) for a particular apps listing, and stores the app store listing information in an output folder.</li>
  <li>The script should extract the following information from the apps page: <code>icon</code>, <code>title</code>, <code>description</code> and <code>screenshots</code>.</li>
  <li>I should be able to run the script by the following command: <code>python app_fetcher.py &lt;app_id&gt;</code>.  The metadata should then be stored in a folder in the current directory (e.g. <code>./&lt;app_id&gt;</code>)</li>
  <li>Bonus Points!  Also fetch the apps store listing subtitle, or anything else you find interesting.</li>
  </ul>
  
  <p>I have made a start on this but am not sure how to actually go about doing the web scraping part of the script. Would anyone be able to advise. I don't know what libraries to use or functions to call. I have looked online but it all involves installing additional packages. Here is what I have so far, any help would be appreciated!!!...</p>
  
  <pre><code># Function to crawl Google Play Store and obtain data
  def web_crawl(app_id):
   import os, sys, urllib2
   try:
    # Obtain the URL for the app
    url = "https://play.google.com/store/apps/details?id=" + app_id
  
    # open url for reading
    response = urllib2.urlopen(url)
  
    # Get path of py file to store txt file locally
    fpath = os.path.dirname(os.path.realpath(sys.argv[0]))
  
    # Open file to store app metadata
    with open(fpath + "\web_crawl.txt", "w") as f:
       f.write("Google Play Store Web Crawler \n")
       f.write("Metadata for " + app_id + "\n")
       f.write("***************************************  \n")
       f.write("Icon: "  + "\n")
       f.write("Title: " + "\n")
       f.write("Description: "  + "\n")
       f.write("Screenshots: "  + "\n")
  
       # Added subtitle 
       f.write("Subtitle: "  + "\n")
  
       # Close file after write
       f.close()
     except urllib2.HTTPError, e:
     print("HTTP Error: ")
     print(e.code)
    except urllib2.URLError, e:
      print("URL Error: ")
      print(e.args)
  
  # Call web_crawl function
  web_crawl("com.cmplay.tiles2")
  </code></pre>