@
ochatokori 感谢
我在测试的时候发现爬虫不加这个签名参数也是可以的。
现在的问题是浏览器上面获取的的数据与爬虫获取到的数据不一致。你有空的话复现帮我看看呀,麻烦了。
浏览器访问: https://删除这几个字
wk588.com/tools/kuangjiduibi爬虫源码:
```
#!/usr/bin/env python3
# coding=utf-8
import requests
import json
import re
def getPage(url):
response = requests.get(url=url)
return response.text
if __name__ == '__main__':
headers = {
'User-Agent':'Mozilla/6.0 (X11; Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.84 Safari/537.36',
'Accept-Encoding': 'gzip, deflate, sdch',
'Accept-Language': 'en-GB,en-US;q=0.8,en;q=0.6'
}
jsonData = getPage('https://删除这几个字
wk588.com/tools/json/qbkuanjiapi.php?n=Bitcoin&dj=0.4&_=1557106802754')
#print(json.loads(jsonData))
minerInfoList = json.loads(jsonData)['data']
# 矿机名称列表
nameList = []
# 算力列表
hashRateList = []
# 功耗列表
powerConsumptionList = []
# 能耗比列表 HashPowerConsumptionRatio
hpcRatioList = []
# 日产值列表
dailyEarnList = []
# 日电费列表
powerChargeList = []
# 电费占比列表
powerChargeRateList = []
# 每日净收益列表
dailyRetainedProfitList = []
for miner in minerInfoList:
if miner['sh'] == 'SHA-256':
minerName = re.sub('<\w.*?\s.*?>.*?','',miner['name'],2)
nameList.append(minerName)
hashRateList.append(miner['kjsn']['xs'])
powerConsumptionList.append(miner['kjgh']['xs'])
hpcRatioList.append(miner['kjdwgh']['xs'])
dailyEarnList.append(miner['rcz']['xs'])
powerChargeList.append(miner['rcdf']['xs'])
powerChargeRateList.append(str(miner['dfzb']['sz'])+'%')
dailyRetainedProfitList.append('¥'+str(miner['rcsy']['sz']))
print(len(nameList))
for i in range(len(nameList)):
print('%-20s' % nameList[i] + '\t' + hashRateList[i] + '\t\t' + powerConsumptionList[i] + '\t\t' + dailyEarnList[i])
```