python 爬取简单的双色球走势图数据

import lxml.html
import requests
response = requests.get('http://trend.caipiao.163.com/ssq/').text
result = lxml.html.fromstring(response)
result_str = result.xpath('//tbody[@id="cpdata"]/tr')
for i in result_str:
    data = i.xpath('td/text()')[0]
    red = i.xpath('td[@class="ball_red"]/text()')
    brown = i.xpath('td[@class="ball_brown"]/text()')
    blue = i.xpath('td[@class="ball_blue js-fold"]/text()')
    print(data,red,brown,blue)

你可能感兴趣的:(爬虫)