爬虫练手,爬取新浪双色彩,信息并进行分析

爬虫练手,爬取新浪双色彩,信息并进行分析

import requests
from lxml.html import etree



url = 'http://zst.aicai.com/ssq/betOrder/'
response = requests.get(url)
response_html = etree.HTML(response.text)
text_path = '/html/body/div[7]/form/div[2]/table/tbody/tr/td/text()'
data_list = response_html.xpath(text_path)
print(data_list)

count = 0
for a in data_list:
    
    if count == 0: print(f'期号:{a}')
    elif count == 1: print(f'日期:{a}')
    elif count == 2: print(f'出球顺序:{a}',end = '')
    elif count in (3,4,5,6): print(f'{a}',end = '')
    elif count == 7: print(f'{a}')
    elif count == 8: print(f'红球号码:{a}', end='')
    elif count in (9, 10, 11, 12): print(f'{a}', end='')
    elif count == 13: print(f'{a}')
    elif count == 14: print(f'蓝球号码:{a}')

    count += 1
    if count == 15: count = 0
posted @ 2019-07-08 18:23  小小咸鱼YwY  阅读(840)  评论(0编辑  收藏  举报