04-18-2013, 11:48 AM
I have tried getting an answer from stackoverflow.com, but no-one seems to know it. So here it goes:
I am trying to write this program to find out which stocks are good to buy. When I try to execute it, it gives me the following result:
msft 28.81 Traceback (most recent call last): File "C:/Users/Myname/Desktop/Stock.py", line 11, in print(o.group(1)) AttributeError: 'NoneType' object has no attribute 'group'
This is in python 3.3 on Windows Proffesional 64 bit. I am using Urllib as well. Can anyone help please?
The website I am getting data from is Yahoo finance MSFT (Microsoft.
Code:
sorry guys here is the code:
from urllib import request
import re
import urllib
websites = ['msft','aapl','ddd','intc','csco','goog','mcd','s']
for i in websites:
url = ("http://ca.finance.yahoo.com/q?s="+i+"&ql=1")
html = urllib.request.urlopen(url)
data = re.search(r'<span id="yfs_l84_([\w]+)">([\w.]+)</span>',str(html.read()))
fifty_two_week_high = re.search(r'<span>([\w.]+)</span>',str(html.read()))
print(data.group(1),data.group(2))
print(fifty_two_week_high.group(1))
I am trying to write this program to find out which stocks are good to buy. When I try to execute it, it gives me the following result:
msft 28.81 Traceback (most recent call last): File "C:/Users/Myname/Desktop/Stock.py", line 11, in print(o.group(1)) AttributeError: 'NoneType' object has no attribute 'group'
This is in python 3.3 on Windows Proffesional 64 bit. I am using Urllib as well. Can anyone help please?
The website I am getting data from is Yahoo finance MSFT (Microsoft.
Code:
sorry guys here is the code:
from urllib import request
import re
import urllib
websites = ['msft','aapl','ddd','intc','csco','goog','mcd','s']
for i in websites:
url = ("http://ca.finance.yahoo.com/q?s="+i+"&ql=1")
html = urllib.request.urlopen(url)
data = re.search(r'<span id="yfs_l84_([\w]+)">([\w.]+)</span>',str(html.read()))
fifty_two_week_high = re.search(r'<span>([\w.]+)</span>',str(html.read()))
print(data.group(1),data.group(2))
print(fifty_two_week_high.group(1))