Skip to content

Commit

Permalink
Merge pull request gocolly#493 from kewei5zhang/issue/outdated-exampl…
Browse files Browse the repository at this point in the history
…e-coinmarketcap

update outdated cryptocoinmarketcap example
  • Loading branch information
asciimoo authored May 26, 2020
2 parents a32f979 + b4312dc commit 556442d
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions _examples/cryptocoinmarketcap/cryptocoinmarketcap.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,22 @@ func main() {
defer writer.Flush()

// Write CSV header
writer.Write([]string{"Name", "Symbol", "Price (USD)", "Volume (USD)", "Market capacity (USD)", "Change (1h)", "Change (24h)", "Change (7d)"})
writer.Write([]string{"Name", "Symbol", "Market Cap (USD)", "Price (USD)", "Circulating Supply (USD)", "Volume (24h)", "Change (1h)", "Change (24h)", "Change (7d)"})

// Instantiate default collector
c := colly.NewCollector()

c.OnHTML("#currencies-all tbody tr", func(e *colly.HTMLElement) {
c.OnHTML("tbody tr", func(e *colly.HTMLElement) {
writer.Write([]string{
e.ChildText(".currency-name-container"),
e.ChildText(".col-symbol"),
e.ChildAttr("a.price", "data-usd"),
e.ChildAttr("a.volume", "data-usd"),
e.ChildAttr(".market-cap", "data-usd"),
e.ChildAttr(".percent-change[data-timespan=\"1h\"]", "data-percentusd"),
e.ChildAttr(".percent-change[data-timespan=\"24h\"]", "data-percentusd"),
e.ChildAttr(".percent-change[data-timespan=\"7d\"]", "data-percentusd"),
e.ChildText(".cmc-table__column-name"),
e.ChildText(".cmc-table__cell--sort-by__symbol"),
e.ChildText(".cmc-table__cell--sort-by__market-cap"),
e.ChildText(".cmc-table__cell--sort-by__price"),
e.ChildText(".cmc-table__cell--sort-by__circulating-supply"),
e.ChildText(".cmc-table__cell--sort-by__volume-24-h"),
e.ChildText(".cmc-table__cell--sort-by__percent-change-1-h"),
e.ChildText(".cmc-table__cell--sort-by__percent-change-24-h"),
e.ChildText(".cmc-table__cell--sort-by__percent-change-7-d"),
})
})

Expand Down

0 comments on commit 556442d

Please sign in to comment.