Hi!
Im trying to get a better overview of my portfolio. So im trying to make a script to make it happen.
The script should take the ticker info from this website: http ://bors.e24.no/e24.no/site/stock/stock_detail.page?magic=(cc%20(detail%20(tsid%2053786))) (example stock)
Once I retrieve the information I want to use it on my homepage to automaticly calculate what my portfolio is worth.
Could anyone point me in the right direction of what I need to do?
Web scraping to get stock info
Started by ahdrage, Sep 26 2009 10:17 AM
9 replies to this topic
#1
Posted 26 September 2009 - 10:17 AM
|
|
|
#2
Posted 26 September 2009 - 08:37 PM
You could always post a job in the freelancer section, and someone could write the program for you.
Otherwise, the easiest way would be to go with PHP and use regex to parse what you needed from the page.
Otherwise, the easiest way would be to go with PHP and use regex to parse what you needed from the page.
#3
Posted 27 September 2009 - 07:12 AM
Yea just grab the page (ton of functions to do this) then use some regular expressions to get the information you needed from this, i'd probably try and find a rss feed that makes it a ton easier to use this information.
#4
Posted 27 September 2009 - 11:15 AM
I would use wget or Lynx,
but you could also use curl, file_get_contents or fopen
depends on your environment and what you know.
Good Luck :)
but you could also use curl, file_get_contents or fopen
depends on your environment and what you know.
Good Luck :)
#5
Posted 28 September 2009 - 09:34 AM
Thanks for your suggestions guys. I will look into all of them. I've done some programming before, but don't have a lot of experience. But I like a challenge :)
I now used firebug to find where in the sourcecode the price of the stock comes from. If you open the link I gave in the first post, the stock price comes in the <H1> tag.
So I could forexample use regex to get the price from the <H1> tag?
I now used firebug to find where in the sourcecode the price of the stock comes from. If you open the link I gave in the first post, the stock price comes in the <H1> tag.
So I could forexample use regex to get the price from the <H1> tag?
#6
Posted 28 September 2009 - 11:59 AM
#7
Posted 17 October 2009 - 07:27 PM
Have you tried irobotsoft web scraper? You really don't need much programming skill to make it work.
#8
Posted 21 October 2009 - 09:17 AM
Biterscripting is one scripting language you ought to try if you are downloading stock quotes and doing further processing. I wrote a quick script for you. Let's say you have 70 shares of IBM and 80 shares of MSFT.
I have tested this script. It shows me
As I mentioned, script is in biterscripting. To try, save the above script in file C:/Scripts/portfolio.txt, start biterscripting. Then enter the following command.
script "C:/Scripts/portfolio.txt"
You should see the same results. The stock symbols and share counts can be read from a file or spreadsheet, instead of hardcoding.
(Sorry, I could not work with e24.no. I could not understand the language so I did not know which number meant what. For example, if the number 123.18, meant last trade, average price, low, high or what.)
Jenni
#Script portfolio.txt
var real price, value, total
var str data
# Get IBM data.
script ss_webpagetocsv.txt page("http: //finance.yahoo.com/q?s=IBM") number(1) > $data
lex "1" $data > $data ; wex "1" $data > $data
set $price = makereal(str($data))
set $value = $price * 70
set $total = $total + $value
echo "IBM: " $price " " $value " " $total
# Get MSFT data.
script ss_webpagetocsv.txt page("http: //finance.yahoo.com/q?s=MSFT") number(1) > $data
lex "1" $data > $data ; wex "1" $data > $data
set $price = makereal(str($data))
set $value = $price * 80
set $total = $total + $value
echo "MSFT: " $price " " $value " " $total
# Show portfolio value.
echo "Portfolio: $" $total " *** Congratulations ***"
I have tested this script. It shows me
Quote
IBM: 123.18 8622.60 8622.60
MSFT: 26.64 2131.20 10753.80
Portfolio: $10753.80 *** Congratulations ***
MSFT: 26.64 2131.20 10753.80
Portfolio: $10753.80 *** Congratulations ***
As I mentioned, script is in biterscripting. To try, save the above script in file C:/Scripts/portfolio.txt, start biterscripting. Then enter the following command.
script "C:/Scripts/portfolio.txt"
You should see the same results. The stock symbols and share counts can be read from a file or spreadsheet, instead of hardcoding.
(Sorry, I could not work with e24.no. I could not understand the language so I did not know which number meant what. For example, if the number 123.18, meant last trade, average price, low, high or what.)
Jenni
#9
Posted 21 October 2009 - 02:55 PM
With so many mature, proven FOSS scripting languages/environments
out there, why use an unproven obscure commercially licensed language/environment.
free trial license??? :thumbdown:
out there, why use an unproven obscure commercially licensed language/environment.
free trial license??? :thumbdown:
#10
Posted 11 January 2011 - 05:54 AM
thats great


Sign In
Create Account

Back to top










