Python爬虫项目实例——爬取【乐彩网】双色球历史获奖红蓝球数据

爬取【乐彩网】双色球历史获奖红蓝球数据
最终存到excel中
爬取数据要求为:
在这里插入图片描述
代码如下:

import requests
from lxml.html import etree
import re

cookies = {
   
	'PHPSESSID': 'p9hhd41uma2qtffng5vu1c8pa4',
	'pgv_pvi': '9924044800',
	'pgv_si': 's9373211648',
}

headers = {
   
	'Connection': 'keep-alive',
	'Cache-Control': 'max-age=0',
	'Upgrade-Insecure-Requests': '1',
	'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36',
	'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
	'Accept-Language': 'zh-CN,zh;q=0.9',
}

all_detail_links_list = []

def all_17500():
	response = requests.get('http://www.17500.cn/ssq/all.php', headers=headers, cookies=cookies, verify=False)
	res_html = etree.HTML(response.text)
	old_LeCaiNet_links = res_html.xpath('//font[@id="SF"]/a/@href')
	old_LeCaiNet_links_list = []
	for old_LeCaiNet_link in old_LeCaiNet_links:
		old_LeCaiNet_link = 'http://www.17500.cn/ssq/'+old_LeCaiNet_link
		old_LeCaiNet_links_list.append(old_LeCaiNet_link)
	oldyear_17500(old_LeCaiNet_links_list)  #取出老旧年份的各期链接
	new_LeCaiNet_links = res_html.xpath('//font[@id="SF"]/p/a/@href')
	for new_LeCaiNet_link in new_LeCaiNet_links:
		new_L
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值