Here is a small program that can create list of companies listed at NYSE (New York Stock Exchange). I created the script to help a friend of mine who has a itch for “stock analysis”.

<?php
$files = range('A', 'Z');
$files[] = 'Other';
 
$curl = curl_init();
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
 
foreach ($files as $f) {
  $url = "http://www.nyse.com/about/listed/lc_ny_name_${f}.js";
  curl_setopt($curl, CURLOPT_URL, $url);
  $content = curl_exec($curl);
  // get symbol from JS
  preg_match_all('%\[\"(\w*)\",%', $content, $matches);
  foreach($matches[1] as $symbol) {
    echo "$symbol\n";
  }
}
?>

I’ll upload the complete list somewhere to make it more handy.

Cheers,

Posted Thursday, September 25th, 2008 at 1:28 pm
Filed Under Category: Financial World
You can skip to the end and leave a response. Pinging is currently not allowed.

0

Leave a Reply

CAPTCHA image