我的 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。我将如何解决这个问题?