coinmarketcap.com爬虫
Posted xm17
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了coinmarketcap.com爬虫相关的知识,希望对你有一定的参考价值。
coinmarketcap.com爬虫
写的真是蛋疼
# -*- coding:utf-8 -*- import requests from lxml import etree headers = { ‘user-agent‘:‘Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (Khtml, like Gecko) Chrome/68.0.3440.106 Safari/537.36‘ } def get_tag(): html = requests.get("https://coinmarketcap.com/zh/rankings/exchanges/",headers=headers).text keys = etree.HTML(html) keyss = keys.xpath("//td[@class=‘no-wrap currency-name‘]/@data-sort") for i in keyss: url = "https://coinmarketcap.com/zh/exchanges/"+i get_url(url) def get_url(url): html = requests.get(url, headers=headers).text keys = etree.HTML(html) keyss = keys.xpath("//div[@class=‘col-xs-12‘]/ul[@class=‘list-unstyled‘]/li/a/@href") for i in keyss: print i break if __name__ == ‘__main__‘: get_tag()
以上是关于coinmarketcap.com爬虫的主要内容,如果未能解决你的问题,请参考以下文章
如何从 Coinmarketcap 解析历史 BTC 数据?