|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import requests
from lxml import etree
import openpyxl
wb = openpyxl.Workbook()
ws = wb.active
ws.append(["日期","第一个红球", "第二个红球","第三个红球","第四个红球","第五个红球","第六个红球","蓝球"])
print("请输入开始的期数:",end="")
begin=input("")
print("请输入节束的期数:",end="")
over=input("")
address=("http://datachart.500.com/ssq/history/newinc/history.php?start="+ begin + "&end="+ over)
url = address
response = requests.get(url)
response = response.text
selector = etree.HTML(response)
for i in selector.xpath('//tr[@class="t_tr1"]'):
datetime = i.xpath('td/text()')[0]
red = i.xpath('td/text()')[1:7]
blue = i.xpath('td/text()')[7]
red.insert(0,datetime)
red.append(blue)
ws.append(red)
wb.save("ball_test.xlsx")
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\001.py", line 1, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
本帖最后由 松_HWI3H 于 2019-8-27 08:03 编辑
原因:系统检测到没有requests库
解决办法:安装requests库,在cmd中输入pip install requests 就可以了,楼主最好看一下其他库有没有安装,可在cmd中输入pip list查看
|
|