public class GoogleFinanceScraper extends UrlScraper
Modifier and Type | Field and Description |
---|---|
static String |
COL_DELIM |
private JsonObject |
dataHome |
(package private) String |
gLoginFormElement |
(package private) String |
gLoginUrl |
(package private) String |
gLoginUrl_plong |
(package private) String |
gLoginUrl_pshort |
private String |
googleFinanceFilename_ |
(package private) String |
gPassword |
(package private) String |
gPasswordElement |
(package private) String |
gScrapePageUrl |
(package private) String |
gScrapeQuoteEnd |
(package private) String |
gScrapeQuoteEnd_ |
(package private) String |
gScrapeQuoteStart |
(package private) String |
gScrapeQuoteStart_ |
(package private) static String |
gScrapeQuoteTokenizedUrl |
(package private) String |
gUserLoginElement |
(package private) String |
gUsername |
private JsonArray |
holdings |
static String |
QUOTE_MARKET_TOKEN |
static String |
QUOTE_SYMBOL_TOKEN |
protected String |
quoteStringCache_ |
(package private) HashMap<String,String> |
reqProps |
static String |
SYSTEM_FILE_SEPERATOR
A holder for this clients System File Separator.
|
static String |
SYSTEM_LINE_SEPERATOR
A holder for this clients System line termination separator.
|
static String |
USERHOME
The users home ditrectory.
|
alreadyLoggedIn_, baseUrl_, cm_, connection_, cookies_, dateStr_, debugOut_, marketSymbolCache_, postPageResponse_, rightNow_, stockSymbolCache_, USER_AGENT
Constructor and Description |
---|
GoogleFinanceScraper()
Default constructor for the Yahoo!
|
Modifier and Type | Method and Description |
---|---|
boolean |
doLogin()
Not needed because this is a open webpage.
|
double |
getDaysHigh(String stockSymbol,
String marketSymbol)
Get the latest stock Days High price .
|
private double |
getDaysHighNew(String stockSymbol,
String marketSymbol)
Get the latest stock Days High price from the NEW GFinance pages Circa 2018.
|
private double |
getDaysHighOld(String stockSymbol,
String marketSymbol)
Get the latest stock Days High price from the Old GFinance pages before 2018.
|
double |
getDaysLow(String stockSymbol,
String marketSymbol)
Get the latest stock Days Low price .
|
private double |
getDaysLowNew(String stockSymbol,
String marketSymbol)
Get the latest stock Days Low price from the NEW GFinance pages Circa 2018.
|
private double |
getDaysLowOld(String stockSymbol,
String marketSymbol)
Get the latest stock Days Low price .
|
double |
getDividendYieldOld(String stockSymbol,
String marketSymbol)
Get the latest stock Dividend Yield.
|
double |
getLatestDividend(String stockSymbol,
String marketSymbol)
Get the latest stock Div Yield %.
|
private double |
getLatestDividendNew(String stockSymbol,
String marketSymbol)
Get the latest stock Div Yield % from the NEW GFinance pages Circa 2018.
|
private double |
getLatestDividendOld(String stockSymbol,
String marketSymbol)
Get the latest stock Dividend Yield % .
|
double |
getOpen(String stockSymbol,
String marketSymbol)
Get the latest stock Open price.
|
private double |
getOpenNew(String stockSymbol,
String marketSymbol)
Get the latest stock Open price from the NEW GFinance pages Circa 2018.
|
private double |
getOpenOld(String stockSymbol,
String marketSymbol)
Get the latest stock Open price from the OLD GFinance Pages .
|
String |
getPortfolioString()
Create the Portfolio data string for the CR account for today.
|
String |
getPortfolioString(boolean resultSetOnly)
Create the Portfolio data string for the CR account for today.
|
String |
getPortfolioSummaryString()
Create the Portfolio Summary data string for the CR account for today.
|
double |
getQuote(String stockSymbol,
String marketSymbol)
Get the latest stock QUOTE .
|
private double |
getQuoteNew(String stockSymbol,
String marketSymbol)
Get the latest stock QUOTE from new Website Circa 2018.
|
private double |
getQuoteOld(String stockSymbol,
String marketSymbol)
Get the latest stock QUOTE using old website.
|
private String |
getQuoteString(String stockSymbol,
String marketSymbol)
Requests, scrapes and creates the stock QUOTE data string for the given stock symbol for today.
|
private String |
getQuoteString(String stockSymbol,
String marketSymbol,
boolean useCache) |
String |
getStockDailyString(String stockSymbol)
Create the STOCK_DAILY data string for the given stock symbol for today.
|
static String |
getStockPageUrlStr(String stockSymbol,
String marketSymbol)
Returns the URL string to the Google page for the specified stock.
|
String |
getTodaysTSXChartAndTableHtmlStr() |
String |
getTodaysTSXChartAndTableHtmlStr(boolean includeTable)
Get the days TSX Index chart and data .
|
double |
getVolume(String stockSymbol,
String marketSymbol)
Get the latest stock Volume.
|
private double |
getVolumeNew(String stockSymbol,
String marketSymbol)
Get the latest stock Volume from the NEW GFinance pages Circa 2018 - IF IT EXISTED.
|
private double |
getVolumeOld(String stockSymbol,
String marketSymbol)
Get the latest stock Volume .
|
static String |
googleMarketSymbol(String mkt) |
private boolean |
loadProperties()
Load the private properties from an external/private file.
|
static void |
main(String[] args) |
String |
right(String value,
int length) |
private double |
scrapeValueNew(String stockSymbol,
String marketSymbol,
String valueName)
Get the latest stock stat for the passed in valueName from the NEW GFinance pages Circa 2018.
|
protected void |
test(String[] args)
Test method to do whatever tests I want.
|
doLogin, doScrape, doScrape, doScrape, doScrape, doScrape, doScrape, doScrape, doScrape, doScrape, getBaseUrl, getConnection, getCookies, getDebugOut, getLoginFormID, getLoginFormParams, getLoginUrl, getPageContent, getPageContent, getPassword, getPasswordFormElementName, getRequestProps, getScrapeEnd, getScrapePageUrl, getScrapeStart, getUsername, getUsernameFormElementName, prettyJson, readFileToString, sendPost, setBaseUrl, setConnection, setCookies, setDebugOut, setDebugOut, setLoginFormID, setLoginUrl, setPassword, setPasswordFormElementName, setRequestProps, setScrapeEnd, setScrapePageUrl, setScrapeStart, setUsername, setUsernameFormElementName, test, toJsonObject, toJsonStructure, writeStringToFile, writeStringToFile
public static final String SYSTEM_FILE_SEPERATOR
public static final String SYSTEM_LINE_SEPERATOR
public static final String COL_DELIM
public static final String QUOTE_SYMBOL_TOKEN
public static final String QUOTE_MARKET_TOKEN
private String googleFinanceFilename_
String gLoginUrl_plong
String gLoginUrl_pshort
String gScrapePageUrl
static String gScrapeQuoteTokenizedUrl
String gLoginFormElement
String gUserLoginElement
String gPasswordElement
String gScrapeQuoteStart
String gScrapeQuoteStart_
String gScrapeQuoteEnd
String gScrapeQuoteEnd_
private JsonObject dataHome
protected String quoteStringCache_
public GoogleFinanceScraper()
private boolean loadProperties()
public boolean doLogin()
doLogin
in class UrlScraper
private double getQuoteOld(String stockSymbol, String marketSymbol)
stockSymbol
- is the Symbol of the stock to lookupmarketSymbol
- is the stock market symbol that Google uses in the quoteUrlprivate double getQuoteNew(String stockSymbol, String marketSymbol)
stockSymbol
- is the Symbol of the stock to lookupmarketSymbol
- is the stock market symbol that Google uses in the quoteUrlpublic double getQuote(String stockSymbol, String marketSymbol)
stockSymbol
- is the Symbol of the stock to lookupmarketSymbol
- is the stock market symbol that Google uses in the quoteUrlpublic String getTodaysTSXChartAndTableHtmlStr()
public String getTodaysTSXChartAndTableHtmlStr(boolean includeTable)
private double scrapeValueNew(String stockSymbol, String marketSymbol, String valueName)
stockSymbol
- is the Symbol of the stock to lookupmarketSymbol
- is the stock market symbol that Google uses in the quoteUrlvalueName
- is the stat to scrape - Open, Close, High, Low, 52-wk high, 52-wk low, Div yieldprivate double getOpenOld(String stockSymbol, String marketSymbol)
stockSymbol
- is the Symbol of the stock to lookupmarketSymbol
- is the stock market symbol that Google uses in the quoteUrlprivate double getOpenNew(String stockSymbol, String marketSymbol)
stockSymbol
- is the Symbol of the stock to lookupmarketSymbol
- is the stock market symbol that Google uses in the quoteUrlpublic double getOpen(String stockSymbol, String marketSymbol)
stockSymbol
- is the Symbol of the stock to lookupmarketSymbol
- is the stock market symbol that Google uses in the quoteUrlprivate double getDaysHighOld(String stockSymbol, String marketSymbol)
stockSymbol
- is the Symbol of the stock to lookupmarketSymbol
- is the stock market symbol that Google uses in the quoteUrlprivate double getDaysHighNew(String stockSymbol, String marketSymbol)
stockSymbol
- is the Symbol of the stock to lookupmarketSymbol
- is the stock market symbol that Google uses in the quoteUrlpublic double getDaysHigh(String stockSymbol, String marketSymbol)
stockSymbol
- is the Symbol of the stock to lookupmarketSymbol
- is the stock market symbol that Google uses in the quoteUrlprivate double getDaysLowOld(String stockSymbol, String marketSymbol)
stockSymbol
- is the Symbol of the stock to lookupmarketSymbol
- is the stock market symbol that Google uses in the quoteUrlprivate double getDaysLowNew(String stockSymbol, String marketSymbol)
stockSymbol
- is the Symbol of the stock to lookupmarketSymbol
- is the stock market symbol that Google uses in the quoteUrlpublic double getDaysLow(String stockSymbol, String marketSymbol)
stockSymbol
- is the Symbol of the stock to lookupmarketSymbol
- is the stock market symbol that Google uses in the quoteUrlprivate double getLatestDividendOld(String stockSymbol, String marketSymbol)
stockSymbol
- is the Symbol of the stock to lookupmarketSymbol
- is the stock market symbol that Google uses in the quoteUrlprivate double getLatestDividendNew(String stockSymbol, String marketSymbol)
stockSymbol
- is the Symbol of the stock to lookupmarketSymbol
- is the stock market symbol that Google uses in the quoteUrlpublic double getLatestDividend(String stockSymbol, String marketSymbol)
stockSymbol
- is the Symbol of the stock to lookupmarketSymbol
- is the stock market symbol that Google uses in the quoteUrlprivate double getVolumeOld(String stockSymbol, String marketSymbol)
stockSymbol
- is the Symbol of the stock to lookupmarketSymbol
- is the stock market symbol that Google uses in the quoteUrlprivate double getVolumeNew(String stockSymbol, String marketSymbol)
stockSymbol
- is the Symbol of the stock to lookupmarketSymbol
- is the stock market symbol that Google uses in the quoteUrlpublic double getVolume(String stockSymbol, String marketSymbol)
stockSymbol
- is the Symbol of the stock to lookupmarketSymbol
- is the stock market symbol that Google uses in the quoteUrlpublic double getDividendYieldOld(String stockSymbol, String marketSymbol)
stockSymbol
- is the Symbol of the stock to lookupmarketSymbol
- is the stock market symbol that Google uses in the quoteUrlpublic static String getStockPageUrlStr(String stockSymbol, String marketSymbol)
private String getQuoteString(String stockSymbol, String marketSymbol)
stockSymbol
- is the Symbol of the stock to lookupmarketSymbol
- is the stock market symbol that Google uses in the quoteUrlprivate String getQuoteString(String stockSymbol, String marketSymbol, boolean useCache)
public String getStockDailyString(String stockSymbol)
stockSymbol
- is the Symbol of the stock to lookup *public static String googleMarketSymbol(String mkt)
public String getPortfolioSummaryString()
public String getPortfolioString()
public String getPortfolioString(boolean resultSetOnly)
resultSetOnly
- true to return only the default delimited resultSet OR false to send a longer more readable stringprotected void test(String[] args)
test
in class UrlScraper
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses