Skip to content

Instantly share code, notes, and snippets.

@thepycoach
Last active September 5, 2021 03:27
Show Gist options
  • Select an option

  • Save thepycoach/9c95d71d49f41ec5ffedd6f036426740 to your computer and use it in GitHub Desktop.

Select an option

Save thepycoach/9c95d71d49f41ec5ffedd6f036426740 to your computer and use it in GitHub Desktop.
import scrapy
class WorldometersSpider(scrapy.Spider):
name = 'worldometers'
allowed_domains = ['www.worldometers.info']
start_urls = ['https://www.worldometers.info/world-population/population-by-country/']
def parse(self, response):
# Getting all the rows of the table
rows = response.xpath('//tr')
for row in rows:
# Extracting country names and population
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment