c++ 从命令行获取参数
When I conned my way into my first professional programming gig, I didn't really think much about money -- just that I was getting my foot in the door. But as my career has gone on, I've been more aware of money, investing, and retirement. I've recently regretfully gotten into stock trading -- you can imagine how many times a day I hit the ole F5 to see updated quotes, praying my investments push higher.
当我进入自己的第一个专业编程专区时,我并没有真正想过钱-只是我正在步入正轨。 但是随着我事业的发展,我对金钱,投资和退休有了更多的了解。 我最近 遗憾地 进入股票交易-您可以想象我一天打几次ole F5来查看更新的报价,祈祷我的投资增加。
I also spend a large part of my day in iTerm, so switching back and forth between the browser and the terminal is time-consuming and annoying. I looked for a way to get stock quotes from the command line, and thanks to Yahoo, it's a simple process!
我还在iTerm中度过了大部分时间,因此在浏览器和终端之间来回切换既费时又烦人。 我正在寻找一种从命令行获取股票报价的方法,感谢Yahoo,这是一个简单的过程!
获取当前价格 (Get Current Price)
Since cURL is amazing and easy to use, we'll roll with that:
由于cURL非常棒且易于使用,因此我们将介绍以下内容:
#One stock
curl -s 'http://download.finance.yahoo.com/d/quotes.csv?s=aapl&f=l1'
#Multiple stocks, separated by comma
curl -s 'http://download.finance.yahoo.com/d/quotes.csv?s=aapl,meip&f=l1'
Yahoo! Finance's information, which is fairly "real time", provides quotes within the s
parameter and the f
parameter of l1
provides the formatted result.
雅虎! 财务信息相当“实时”,在s
参数中提供了引号,而l1
的f
参数提供了格式化的结果。
通过更改获取当前价格 (Get Current Price with Change)
If you'd like to know the amount changed on the day, tag c1
to the f
parameter:
如果您想知道当天的金额变化,请将c1
标记为f
参数:
curl -s 'http://download.finance.yahoo.com/d/quotes.csv?s=aapl&f=l1c1'
Not needing to jump over to the browser to get stock quotes has been nice...especially if the market is having a down day and you don't want to see a screen of red. Booooo.
无需跳到浏览器即可获得股票报价非常好……尤其是在市场低迷且您不想看到红色屏幕的情况下。 Booooo。
c++ 从命令行获取参数