Hey Guys. I am looking at making a app to check my work schedule and place it into a Google calendar. I know some java and I can get my activities to write to a file and such.
Basically, the parts I'm struggling with are reading from the web page where i get my schedule. I want to work on that first and basically parse the returned website into separate days and hours scheduled.
I'll upload some screen shots and source code for the web page. Of course, I cannot give you my password and username for you all to test these for yourself, but I have checked and I may let you use the source code.
Device(s): Nexus 4, Samsung Galaxy S II, HTC Evo 4G, Amazon Kindle Fire
Carrier: ATT
Thanks: 235
Thanked 463 Times in 286 Posts
Mmkay, I am willing to bet that your calendar is generated via javascript using a database of some sort, which means that it isn't pure HTML. Because of this, you can't really parse the web page. You would need to find out the database information, such as address, username, and password (Which I highly doubt Best Buy would give you) and then perform queries on that database to retrieve the information you need.
__________________
My blog, Inverted Keystrokes, is looking for aspiring developers (not necessarily with Android) to post articles. If you have any development experience and are interested in participating, please PM me. =)
If you are not the developer of the database on which your work schedule resides, you won't be able to develop the app. You need to know the passwords, have permission, etc., and you need the field names in which the information is stored. Without that, you can't do anything.
well i mean i know that best buy isnt going to give me access to this information. but I can see the code that is returned after the javascript is executed. It shows as html tables in the webpage. once i enter the username and password in the field and click the button. then click another button then right click view source it shows in plain html. is there any way to get it?
i know the app isnt a browser. but i know that there might be a webbrowser class out there. For instance i am also working on a desktop version of this and vb.net has a webBrowser object. i can tell it to navigate to the site through code, enter my login information programmatically and click the button programmatically. after that I can get a list of htmlElements in the webbrowser object and iterate through those to find what I need.
WebBrowser Class (System.Windows.Forms)
this is the vb.net version that i am using. I havent really started looking for a java version yet, but i can probably find something similar
well for example i have a computer version working insofar as opening a window, navigating to the page. then the program can get logged in all the way to the calendar and read it no problem just using a getElementByID method.
A WebView has several customization points where you can add your own behavior. These are:
Creating and setting a WebChromeClient subclass. This class is called when something that might impact a browser UI happens, for instance, progress updates and JavaScript alerts are sent here (see Debugging Tasks).
Creating and setting a WebViewClient subclass. It will be called when things happen that impact the rendering of the content, eg, errors or form submissions. You can also intercept URL loading here (via shouldOverrideUrlLoading()).
Modifying the WebSettings, such as enabling JavaScript with setJavaScriptEnabled().
Injecting Java objects into the WebView using the addJavascriptInterface(Object, String) method. This method allows you to inject Java objects into a page's JavaScript context, so that they can be accessed by JavaScript in the page.
So it looks like i could enable javascript which would make it able to at least run the webpage and sign in. I'll have to do more reading on it to see what i could do about loading the values into the fields.
maybe i could download the html, parse, insert values, render it and then execute javascript and then click the button. idk lots more reading to do and at this point it sounds like even then it would be a popups window that went through these in 10 seconds or so. not something in the background lke i was hoping to make.