http://news.gtimg.cn/notice_more.php?q=sz300144&page=1
如何能用比较简便的方法直接读取 finance_notice ={.....}这段话然后直接将其变成一个字典变量,并把其中的 ASCII 转换成文字。
如何能用比较简便的方法直接读取 finance_notice ={.....}这段话然后直接将其变成一个字典变量,并把其中的 ASCII 转换成文字。
1
XYxe Jun 3, 2017
s = requests.get("http://news.gtimg.cn/notice_more.php?q=sz300144&page=1")
t = s.text[20:-2] t = t.replace("'", '"') json.loads(t) |
2
ruoyu0088 Jun 3, 2017 import requests
res = requests.get("http://news.gtimg.cn/notice_more.php?q=sz300144&page=1") text = res.content.decode() json_text = text[text.find("{"):text.rfind("}") + 1].replace("'", '"') import json json.loads(json_text) |