Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Regex module help
#1
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))
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Module attribute problems. goqe 0 677 03-18-2013, 11:38 AM
Last Post: goqe
  My Doc Module nevets04 0 563 11-19-2009, 04:55 PM
Last Post: nevets04
  Web Search Module Gaijin 0 525 11-03-2009, 09:24 AM
Last Post: Gaijin

Forum Jump:


Users browsing this thread: 1 Guest(s)