下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。
内存溢出小编现在分享给大家,也给大家做个参考。
#!/usr/bin/perl## Script to download a table of daily stock data in .csv format# from yahoo.com## Syntax: yahoo.pl <symbol> <startdate> <stopdate># where startdate and stopdate can be in almost any format#use Date::Manip;($symbol,$startdate,$stopdate)[email protected];$startdate = &ParseDate($startdate);$stopdate = &ParseDate($stopdate);#print "symbol=$symbol start=$startdate stop=$stopdate\n";$startday = &UnixDate($startdate,"%d");$startmon = &UnixDate($startdate,"%m");$startyear = &UnixDate($startdate,"%y");$stopday = &UnixDate($stopdate,"%d");$stopmon = &UnixDate($stopdate,"%m");$stopyear = &UnixDate($stopdate,"%y");$port=80; # http$dataserver="chart.yahoo.com";$AF_INET=2;$SOCK_STREAM=1;$sockaddr='S n a4 x8';($name,$aliases,$proto)=getprotobyname('tcp');($name,$type,$len,$remoteaddr)=gethostbyname($dataserver);$remote=pack($sockaddr,$AF_INET,$port,$remoteaddr);($a,$b,$c,$d)=unpack('C4',$remoteaddr);#print "remoteaddr=$a.$b.$c.$d port=$port\n";if (socket(SOCK,$SOCK_STREAM,$proto)) { #print "Socket OK\n";} else { dIE $!;}if (connect(SOCK,$remote)) { #print "connect OK\n";} else { dIE $!;}$local=getsockname(SOCK);($family,$localaddr)=unpack($sockaddr,$local);($a,$localaddr);#print "remoteaddr=$a.$b.$c.$d port=$port\n";select(SOCK); $|=1; select(STDOUT);print SOCK "GET /table.csv?s=$symbol&a=$startmon&b=$startday&c=$startyear&d=$stopmon&e=$stopday&f=$stopyear&g=d&q=q&y=0&z=$symbol&x=.csv http-1.0\n\n";$start = 0;while (<SOCK>) { if ($start) { ($date,$open,$high,$low,$close,$volume) = split(/,/); ($day,$month,$year) = split('-',$date); $year = int $year; if ($year < 80) { $year = $year + 2000; } $dateint = &ParseDate("$month $day,$year"); $date = &UnixDate($dateint,"%Y/%m/%d"); print $date,' ',$volume; } /^Date/ && ($start = 1);}
以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
总结以上是内存溢出为你收集整理的从 Yahoo.com 获取股票数据(csv格式)全部内容,希望文章能够帮你解决从 Yahoo.com 获取股票数据(csv格式)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)