PureBytes Links
Trading Reference Links
|
gunovanengel wrote:
HI Bill,
Could you provide an example script for scraping this table:
http://moneycentral.msn.com/investor/research/newsnap.asp?Symbol=msft
You need to have Python installed,
save the script with a .py extension and double click on it to run. You
can also run it on the command line like this:
C:\ python scriptname.py
------
#!/usr/bin/env python
import urllib2
from BeautifulSoup import BeautifulSoup
html =
urllib2.urlopen("http://moneycentral.msn.com/investor/research/newsnap.asp?Symbol=msft").read()
soup = BeautifulSoup(html)
header = soup('h1')[0].string
s = '%s\n\n' % (header)
latest = soup.firstText('Quick Quote').findNext('tr')
s = s + '%-20s---%13s\n' % (latest('td')[1].string,
latest('td')[2]('b')[0].string)
change = latest.findNext('tr')
s = s + '%-20s---%13s\n' % (change('td')[1].string,
change('td')[2]('span')[0].string)
pchange = change.findNext('tr')
s = s + '%-20s---%13s\n' % (pchange('td')[1].string,
pchange('td')[2]('span')[0].string)
close = pchange.findNext('tr')
s = s + '%-20s---%13s\n' % (close('td')[1].string,
close('td')[2].string)
low = close.findNext('tr')
s = s + '%-20s---%13s\n' % (low('td')[1].string, low('td')[2].string)
high = low.findNext('tr')
s = s + '%-20s---%13s\n' % (high('td')[1].string, high('td')[2].string)
volume = high.findNext('tr')
s = s + '%-20s---%13s\n' % (volume('td')[1].string,
volume('td')[2].string)
scouter = volume.findNext('tr')
s = s + '%-20s---%13s\n' % ('StockScouter Rating',
scouter('td')[2]('a')[0].string)
file('output','w').write(s)
-------
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For other support material please check also:
http://www.amibroker.com/support.html
SPONSORED LINKS
YAHOO! GROUPS LINKS
|
|