Register
It is currently Thu Oct 30, 2014 6:56 am

Set text of website to variable


All times are UTC - 6 hours


Post new topic Reply to topic  [ 5 posts ] 
Author Message
 PostPosted: Thu Jan 26, 2012 11:51 pm   

Joined: Sun Jul 17, 2011 4:21 pm
Posts: 6
Hi Community,
So I'm trying to make a script that will do some stock research for me, so I want to be able to, for example, take all of the text on a webpage like this and set it to a variable so that I can grep for lines like "Total Revenues" and "Operating Income." I'm not all too great with Bash, so a short explanation on what your function(s) and modifiers are doing would be awesome. thanks!


Top
 Profile  
 PostPosted: Mon Jan 30, 2012 4:04 am   
User avatar

Joined: Tue Apr 27, 2010 2:28 pm
Posts: 172
Location: Czech Republic
To get a page to a variable, use
Code:
page=$(wget -O- 'http://finapps.forbes.com/finapps/jsp/finance/compinfo/IncomeStatement.jsp?tkr=AAPL&period=qtr')


But to process tables, I recommend switching to Perl and its HTML::TableExtract.


Top
 Profile  
 PostPosted: Wed Feb 01, 2012 8:16 pm   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 669
Location: Des Moines, Iowa
viewtopic.php?f=7&t=1281


Top
 Profile WWW  
 PostPosted: Sun Feb 05, 2012 2:13 pm   

Joined: Sun Jul 17, 2011 4:21 pm
Posts: 6
Thank you so much for the replies. However, since I'm running the Mac OS, I don't have wget or lynx, so I'm not able to run either of your codes. Are there any Mac OS friendly functions that can accomplish the same thing?


Top
 Profile  
 PostPosted: Sun Feb 05, 2012 4:14 pm   
User avatar

Joined: Tue Apr 27, 2010 2:28 pm
Posts: 172
Location: Czech Republic
I am not sure about Mac OS. Try curl, links, or elinks. You might be able to install some of those from sources even if they are not installed by default.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP