我正在使用scrapy
从here获取一段特定的数据。正如建议的here,我在脚本中使用了以下代码:
pattern = re.compile(r"qubit_product_list = (.*?);", re.M)
script = hxs.select("//script[contains(., 'qubit_product_list')]/text()").extract()[0]
data = pattern.search(script).group(1)
j_data = json.loads(data)
self.log('After calling LOAD Begins')
self.log(j_data) #It is not printing ANYTHING!!!!
self.log('After calling LOAD Ends')
self.log('\n---------------------------------\n')
它从变量data
输出以下内容:
现在,我想将这个类似于json
的结构转换成pythondict
。我尝试了以下操作,但它返回unicode
类型。在
j_data = json.loads(data)
那么,如何在python2.7中获得Array/Dict呢?具有讽刺意味的是,loads
方法在使用scrapy shell
时返回了dict
类型。在
试试这个:
相关问题 更多 >
编程相关推荐