我的python脚本有问题,有一个url,它运行正常,另一个我似乎从另一个网页获取html代码
url = "https://api.bitcoinaverage.com/ticker/USD"
url = "https://satoshidice.com/api/info"
data = urllib.request.urlopen(url)
dataread = data.readall()
datadecode = dataread.decode('utf-8')
print("datadecode:")
print(datadecode)
js = json.loads(datadecode)
print("JS:")
print(js)
当url =“https://api.bitcoinaverage.com/ticker/USD”时 输出:
datadecode:
{
"24h_avg": 230.69,
"ask": 244.3,
"bid": 244.08,
"last": 244.32,
"timestamp": "Tue, 05 Nov 2013 15:02:33 -0000",
"total_vol": 80993.79
}
JS:
{'total_vol': 80993.79, 'last': 244.32, 'timestamp': 'Tue, 05 Nov 2013 15:02:33 -0000', '24h_avg': 230.69, 'ask': 244.3, 'bid': 244.08}
当url =“https://satoshidice.com/api/info”时 输出:
datadecode:
<HTML>
<head>
<style>
<!--
body,td,div,p,a,font,span{ font-family:arial,sans-serif;}
.accent1 {background-color: #DEEFE0}
.accent2 {background-color: #006633}
-->
</style>
<title>How to Enable Cookies</title>
</head>
<body class=search bgcolor=ffffff text=000000 link=0000CC vlink=800080 alink=ff0000 topmargin=3>
<script language="JavaScript">
...
Cookies must be enabled in your browser!</font><br>
从输出中写的最后一行开始,我认为我被发送到另一个URL,因为没有启用cookie。我该如何解决这个问题?