Python List Regex

I have a list from a stock web scraper looking like this: [......', 'xlnx>XLNX<', 'yhoo>YHOO<']

how can I get the dictionary with only the quotes? I know this is simple but I could use some help. Thanks

import urllib
import re

base_url = 'http://www.nasdaq.com/markets/indices/nasdaq-100.aspx'
content = urllib.urlopen(base_url).read()
list = re.findall('http://www.nasdaq.com/symbol/(.*)/a>', content)
print list

Answers


You have a list, not a dictionary. Also you shouldn't name your variable list as it is the name of a built-in.

>>> content
['xlnx>XLNX<', 'yhoo>YHOO<']
>>> tickers = []
>>> for s in content:
...     tickers.append(''.join(i for i in s if i.isupper()))
... 
>>> tickers
['XLNX', 'YHOO']

Need Your Help

Should my PHP functions accept an array of arguments or should I explicitly request arguments?

php method-overloading

In a PHP web application I'm working on, I see functions defined in two possible ways.

socket.send working only once in python code for an echo client

python sockets network-programming

I have the following code for an echo client that sends data to an echo server using socket connection: