14 print "Entry Utils.web_query url ", url
19 f = urllib2.urlopen(url)
25 except urllib2.URLError, e:
29 message_str=
"QueryError with"
30 if hasattr(e,
'reason'):
31 message_str +=
' reason: %s,' % e.reason
32 if hasattr(e,
'code'):
33 message_str +=
' error code: %s' % e.code
37 print "Got general exception from urllib2 ", ex
57 if (
'N/A' in line) | (line.strip() ==
'-'):
64 return float(tmp.join(re.findall(
r'([\d+\s\.\+\-])',line)).replace(
' ',
''))
def check_nan
Check for N/A in Yahoo output, 'N/A' no error.
Specific exception related to the web query (Utils.WebQuery)
Define custom and specific exceptions for the complete package.
def web_query
Execute the url (GET call only, could extend)
def extract_number
Extract a float from a string.