kascepower.blogg.se

Creating a webscraper in python
Creating a webscraper in python












creating a webscraper in python

  • us_gross.append(grosses) tells the scraper to take what we found and stored in grosses and to add it into our empty list called us_grosses (which we created in the beginning).
  • But if the data that’s stored in nv isn’t greater than one - meaning if the gross is missing - then put a dash there.

    creating a webscraper in python

    nv.text if len(nv) > 1 else ‘-’ says if the length of nv is greater than one, then find the second datum that’s stored.

    #CREATING A WEBSCRAPER IN PYTHON CODE#

    nv tells the scraper to go into the nv tag and grab the second data in the list - which is gross because gross comes second in our HTML code.grosses is the variable we’ll use to store the gross we find in the nv tag.votes.append(vote) tells the scraper to take what we found and stored in vote and to add it into our empty list called votes (which we created in the beginning).text tells the scraper to grab that text.nv tells the scraper to go into the nv tag and grab the first data in the list - which are the votes because votes comes first in our HTML code (computers count in binary - they start count at 0, not 1).vote is the variable we’ll use to store the votes we find in the nv tag.( ‘span’, attrs = ‘name’ : ’nv’) is how we can grab attributes of that specific tag.find_all() is the method we’ll use to grab both of the  tags.container is what we used in our for loop for iterating over each time.nv is an entirely new variable we’ll use to hold both the votes and the gross  tags.














    Creating a webscraper in python