webscraping using Phonegap - android

I need to build a cross-platform app (IOS + Android) that requires some web scraping capabilities. What I need it to do is to login on certain sites, grab the relevant information and present a combined overview of data from these sites.
So is there any way to accomplish web scraping in phonegap?

It's easy, just use Ajax to request a page.
Use something like JQuery to make the Ajax easier to work with.
Use JavaScript's regular expressions to extract what you want from the Ajax response. You could also use a Dom parser library of some sort as well for more direct access.
Make sure you have your PhoneGap config set up correctly for making Ajax requests. See AJAX Request from Phonegap Android fails

Related

From ruby on rails website/webapp to Phonegap Android app?

I would like to ask for some advice on this issue I am having. I am working on a website that is made with ruby on rails (along with html.slim, css, angular.js).
I would like to create an Android (and, if possible also iOS/Windows Phone) app to access a part of this website.
The website does nothing more than making some api calls to a server and it's really light, so I think that I don't need to make a native app. I would like to make this app in the fastest and easiest way possible. I thought that I would be able to make convert the site using Phonegap, but this would work if it was made only with html,css and js, not also with ruby on rails. The only thing I need is to store a small string on the device (the website stores a cookie) and then to make a few simple API calls.
Thank you for any advice on this - not so clever - question.
Bye!
PhoneGap, Cordova, Ionic, etc. - all the same. None of them will run your API (aka server side code - PHP, Ruby, .NET) without doing something dramatic.
Easiest approach - write server side services (e.g. REST services) using your favorite server side code - like Ruby, and use JS to securely call into those services.
This fits the PhoneGap/Cordova/Ionic paradigm, and will allow you to build a hybrid app (aka seemingly native app) the quickest.
Just my 2 cents.
Maybe (if you need real simple app for mobile platforms) you should create Android/iOS app with browser object inside app who will be receiving html data from your public website and show it for user. You just need to create mobile layouts in your rails application.
pros:
You can create this app real quickly;
Easy for update;
Don't need to update app if something changed in general web application layouts or logic.
When you create layouts for mobile they will be work for your applications and for mobile devices who doesn't use your app.
cons:
This is not classic application, it just browser inside your app.
It is not a bad solution for start. For most sites, and projects it will be enough.
More information about rails and mobile layouts for rails you can find here:
http://railscasts.com/episodes/199-mobile-devices
Example how looks like android app with browser (Webview) object:
http://www.mkyong.com/android/android-webview-example/
https://developer.chrome.com/multidevice/webview/gettingstarted
I'm sorry if this is not the answer you were looking for.

Communicating to the restful web services in Phonegap

I want to built a mobile application using Phonegap that will communicate with the restful web services and parse the json data.There are two ways two do it:
Calling restful web services using http connection in Java and connecting the Java code to JavaScript file by making our own plug-in in cordova.
2.Making ajax calls to communicate with rest services.
Which one is better considering the needs below:
1.It can call https web service,since for https in android we need to include certificates,create bks file for that which includes lot of mess.
2.It should be able to receive and parse the json data and render it to the html page.
3.We need to built this app for primarily android OS but if we can built it for ios,windows etc. It would be better.
Please tell me if i am using right tool,if sencha touch is easier to perform these tasks?
I would suggest that you use AJAX because it completely fits all your needs, and you gain to use the same code for future use if you'll ever decide to build for more platforms.
moreover, why make things complicated? you already writing your app using javascript, so don't mix it with native code when its unnecessary.
The fact that you choose PhoneGap, it is an indication that you are wanting to re-use your HTML/JS/CSS expertise as much as possible. Say if you choose jQuery Mobile (or any other framework) for your project, jquery provides ajax for your needs already and there is no reason to go down to the JAVA layer.
That said, the right approach should be using the ajax mechanism provided by your javascript framework. This is your option-2 and you won't need to build the raw ajax utilizes. Like if you go with jQuery/jQueryMobile + Backbone + backbone.marionette (we happen to use them in phoneGap app), there are a lot of add-ons out there to help. Like in this example, it is actually part of the phoneGap app under 'www' directory.
Also the communication to the webservice is your least concern if you have all the tools. Making suggestion on what tools to use is not allowed by Stackoverflow:-)

Can jQuery be used to extract data from HTML pages?

I stumbled across jQuery while during a search for my project that involves parsing and extracting content from HTML pages. Wondering if I could use jQuery for this purpose. If so can someone share with me some examples or share links to tutorials?
For instance I would like to parse the top questions on Stackoverflow and display it to the user as a mobile app, mostly Android.
If jQuery is not possible, what are the alternatives ? (The easiest/efficient method of course)
No, jQuery is not the right tool for scraping!
Javascript generally has a same origin policy where you don't have access to cross domain sites. This means you can access files on your own server within the same domain, but not other sites like Stack Overflow, with the exception of sites that have enabled CORS or is using JSONP etc.
Any serverside language, like PHP, RoR, Python, C# etc can be used, whatever you choose is up to you.

Add web project in phonegap

I have web application design only with HTML5, CSS3 and Jquery along with this i have one project with AJAX enabled WCF services to provide endpoints to the HTML pages. I also have couple of projects that have webservices used in my web application.
Now I want to use convert this application into native apps with Phonegap.
please help me on this, forward resources that we can use to convert web application into native android via phonegap.
If you have used only used HTML, JS and CSS in your apps and no server side technologies like ASP.NET or PHP, you can easily get the entire code base running on phone gap. If you need to get the real mobile experience try mobile frameworks like jQuery Mobile or Kendo UI Mobile for UI.

PhoneGap Application reading remote html content

Can I develop hybrid application using phonegap which reads html content at runtime from remote location?
If yes, will it work for both Android as well as iOS?
Yes, this is very easy to do on Android and the comment above provides one way to do it. Another is to make AJAX request for the HTML you want and inject it into your page. However Apple will not like this even though it is technically possible. You are better off requesting data via AJAX and then displaying the data in your app rather than pulling down pure HTML.

Categories

Resources