def handle_data(self, content):
if self.weather_data is not None:<EOL><INDENT>return<EOL><DEDENT>content = content.strip().rstrip('<STR_LIT:;>')<EOL>try:<EOL><INDENT>tag_text = self.get_starttag_text().lower()<EOL><DEDENT>except AttributeError:<EOL><INDENT>tag_text = '<STR_LIT>'<EOL><DEDENT>if tag_text.startswith('<STR_LIT>'):<EOL><INDENT>begin = content.find('<STR_LIT>')<EOL>if begin != -<NUM_LIT:1>:<EOL><INDENT>self.logger.debug('<STR_LIT>')<EOL>end = content.find('<STR_LIT>', begin)<EOL>if end == -<NUM_LIT:1>:<EOL><INDENT>self.logger.debug('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>json_data = self.load_json(<EOL>content[begin:end + <NUM_LIT:1>].split('<STR_LIT:=>', <NUM_LIT:1>)[<NUM_LIT:1>].lstrip()<EOL>)<EOL>if json_data is not None:<EOL><INDENT>def _find_weather_data(data):<EOL><INDENT>'''<STR_LIT>'''<EOL>if isinstance(data, dict):<EOL><INDENT>if '<STR_LIT>' in data and '<STR_LIT>' in data:<EOL><INDENT>return data<EOL><DEDENT>else:<EOL><INDENT>for key in data:<EOL><INDENT>ret = _find_weather_data(data[key])<EOL>if ret is not None:<EOL><INDENT>return ret<EOL><DEDENT><DEDENT><DEDENT>return None<EOL><DEDENT><DEDENT>weather_data = _find_weather_data(json_data)<EOL>if weather_data is None:<EOL><INDENT>self.logger.debug(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>', json_data<EOL>)<EOL><DEDENT>else:<EOL><INDENT>self.weather_data = weather_data<EOL>return<EOL><DEDENT><DEDENT><DEDENT><DEDENT>for line in content.splitlines():<EOL><INDENT>line = line.strip().rstrip('<STR_LIT:;>')<EOL>if line.startswith('<STR_LIT>'):<EOL><INDENT>weather_data = self.load_json(line.split('<STR_LIT:=>', <NUM_LIT:1>)[<NUM_LIT:1>].lstrip())<EOL>if weather_data is not None:<EOL><INDENT>self.weather_data = weather_data<EOL>return<EOL><DEDENT><DEDENT><DEDENT><DEDENT>
Sometimes the weather data is set under an attribute of the "window"
DOM object. Sometimes it appears as part of a javascript function.
Catch either possibility.