Skip to content

Instantly share code, notes, and snippets.

@mottet-dev
Created August 23, 2018 20:36
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 mottet-dev/4ac7580400c8b10b1b007393a794df73 to your computer and use it in GitHub Desktop.
Save mottet-dev/4ac7580400c8b10b1b007393a794df73 to your computer and use it in GitHub Desktop.
Full coinSpider.py
import scrapy
class CoinSpider(scrapy.Spider):
name = "coin"
def start_requests(self):
url = "https://coinmarketcap.com/all/views/all/"
yield scrapy.Request(url=url, callback=self.parse)
def parse(self, response):
for row in response.css("tbody tr"):
yield {
"name": row.css("a.currency-name-container::text").extract_first(),
"symbol": row.css("td.col-symbol::text").extract_first(),
"market_cap": row.css("td.market-cap::text").extract_first(),
"price": row.css("a.price::attr(data-usd)").extract_first(),
"circulating_supply": row.css("td.circulating-supply span::attr(data-supply)").extract_first(),
"volume": row.css("a.volume::attr(data-usd)").extract_first()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment