Python Script

Questions about programming languages and debugging
Post Reply
User avatar
hpprinter100
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 214
Joined: 19 Oct 2007, 16:00
16
Contact:

Python Script

Post by hpprinter100 »

Hello all.

I have an excel file http://www.bankofengland.co.uk/markets/ ... esults.htmthat has loads of ISIN numbers in them. I need to find out which company the ISIN numbers are from so i can see if the purchase of there bonds have impacted on there share price.

The aim is to be able to put all the ISIN in a text file. Then python run all the ISIN codes and get the company name back in a text file.

This would be done by querying the London stock exchange website with the following format
http://www.londonstockexchange.com/exch ... 7ZZGBPCWTR" onclick="window.open(this.href);return false;

with the XS0418995907 being the ISIN which would need to change in each qurey.

Then to get the company name i would need to prase the html to just grab the company name so this is from <h1 class="tesummary">
<a class="title_page_blue" href="/exchange/prices-and-markets/stocks/summary/company-summary.html?fourWayKey=XS0418995907ZZGBPCWTR" title="Go to Company Summary"> 88JL</a>
REED ELSEVIER (INVESTMENTS) PLC 7% GTD NTS 11/12/17 GBP (BR)
</h1>

I would need to get just "REED ELSEVIER (INVESTMENTS) PLC 7% GTD NTS 11/12/17 GBP (BR)"

I don't want someone to code this just some directions on how to do.

Thanks

HP :)

User avatar
leetnigga
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 447
Joined: 28 Jul 2009, 16:00
14

Re: Python Script

Post by leetnigga »

xlrd, urllib/urllib2 and BeautifulSoup. In that order.

I can elaborate if needed, but I'll go and write the script myself first :P

Sounds like interesting stuff you're working on.

User avatar
leetnigga
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 447
Joined: 28 Jul 2009, 16:00
14

Re: Python Script

Post by leetnigga »

Alright, done in 13 lines. Took some thought, though.

You know some of them don't return any results, right? For example XS0182188366 (second ISIN in the spreadsheet) gives you null on that website.

Let me know if you need any help and post your script when you're done :D

User avatar
hpprinter100
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 214
Joined: 19 Oct 2007, 16:00
16
Contact:

Re: Python Script

Post by hpprinter100 »

Yeah that is because some of the bonds are not listed on the london stock exchange

Should of used yahoo really ops so XS0182188366

http://uk.finance.yahoo.com/q?s=XS0182188366&m=L&d=" onclick="window.open(this.href);return false;

buying bonds in British American Tobacco how unethical -.-

User avatar
leetnigga
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 447
Joined: 28 Jul 2009, 16:00
14

Re: Python Script

Post by leetnigga »

Haha.

That source performs a lot better indeed. You could even write a program that tries multiple sources if one doesn't work.

Have you got your script written?

User avatar
hpprinter100
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 214
Joined: 19 Oct 2007, 16:00
16
Contact:

Re: Python Script

Post by hpprinter100 »

No. I have just realised i got to get some applications in so will be doing that, i will have a go later. Please post any interesting companies that are on the list :)

Post Reply