擅长:python、mysql、java
<p>您使用了错误的工具来解析URL返回的json数据。您需要使用默认提供的<a href="http://docs.python.org/2/library/json.html" rel="nofollow">json</a>库,而不是使用<a href="http://docs.python.org/2/library/re.html" rel="nofollow">regex</a>解析数据。
这将提高程序的性能</p>
<p>更改正则表达式分析器</p>
<pre><code>#regular expressions to get all the stream names
self.info = re.sub(r'"teams":\[\{.+?"\}\]', '', self.info) #remove all team names (they have the same name: parameter as streamer names)
self.streamers_names = re.findall('"name":"(.+?)"', self.info) #looks for the name of each streamer in the pile of info
</code></pre>
<p>到json解析器</p>
<pre><code>self.info = json.loads(self.info) #This will parse the json data as a Python Object
#Parse the name and return a generator
return (stream['name'] for stream in data[u'streams'])
</code></pre>