Can jQuery be used to extract data from HTML pages? - android

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.

Related

How to integrate Android app and website?

I have no idea how does applications like Amazon, Flipkart etc work. They have both android application and website. How does data between both web and Android synchronise?
Do we write separate codes for building android app and website? If yes then in what language we build the website so that it's compatible with the android application.
And how to build the database for the same.
If answer is no to the above question, then how exactly do we proceed to build such Android and web application.
I am new to this and want to learn how to build it.
In general, web sites are built with web technologies such as JavaScript, HTML, and CSS, but there a many different frameworks and libraries in other languages (such as Angular, which is written in TypeScript) that can also handle the creation of web apps. In comparison, mobile applications for Android and iOS are written it Java/Kotlin or C#/Swift, respectively. There isn't really a clean, native way to create a single app for web and mobile platforms. But, the data that backs both of the platforms is the same.
How does this work? The data is hosted on what is called a backend, a server that has the information that you want to display to your users. Typically, the client app can get this information with an HTTP request to the backend, and the response will be the data formatted in a JSON string. Data is stored in the backend in a database. There are many databases in use today, but some more popular ones are MySQL, MongoDB, and SQLite, and each of them have their advantages and disadvantages. As you get further along in your development cycle, you will need to choose the tools that work for you.
Websites (and relative applications) like Amazon have very complicated systems behind what you see on the screen. Of course they have different code for either application and website. Usually, in small projects, you can create the mobile android app with languages like Java or Kotlin and websites with html, css and Javascript. But when it comes to get together data between an app and a website, you will need to write backend software, which is not so easy, for example in php and then create a database to store the data (with mySQL for example). Then you can access your data from either app and website and decide what to do with it. I suggest you to learn one of these technologies at a time. Trying to learn them all together will only create misunderstandings.
Hope I've been useful.

Android To Web Database Connection

Can someone give me a broad overview of what pieces would have to be in place to implement a user-content-driven Android app with a web-based database? Or, link me to some helpful relevant articles on web and app architecture to study?
Further, if II already have a website where people can add content and others can vote on it, and I want to have the same capabilities available via an app, utilizing the same central database, how would I proceed?
I'm guessing I could provide remote authentication into the site via the Android app, and then enable the user's content submissions and votes to sync with the database (and website), but how is that handshake process done? And what elements of the site have to be exposed for the app to "connect to"?
Where are lines drawn between a website just being presented inside an Android web view and being made mobile friendly, versus a stand-alone app having the web/database functionality?
I know if I already have a mobile-friendly website, it might seem logical to simply direct people to the mobile site, but obviously a lot of people use apps and there are some benefits over mobile web.
Sorry for such a general question, but I can't seem to find any good examples of people doing this to learn from, even though I imagine it must be very common.
Thanks!
The best practice is to build REST API on server side to manage content from database, and just hook to it with mobile apps. There is a lot of different libraries to do that on both Android/iOS
create your rest api and make it return json.
i think that the better way is to use okhttp http://square.github.io/okhttp/
for http connection,
retrofit and gson http://square.github.io/retrofit/
for parsing json results;

Architecture for iOS and Android Project using web view loading html and js from server (singe code base)

We have recently started a Hybrid project(?) to work on iOS as well as Android with the following specifications:
Html pages, Javascript file, Jquery based libraries files and resource files (Images) are hosted on a server.
The hybrid code (iOS or android) loads the html pages in the web view and the page navigation and event handling is completely like any normal html and js based website. We have taken care of CORS for AJAX web service calls. The data is basically stored as local storage(browser's support).
Most of the data that is viewed by the user is live from web service calls, Except some of the images captured using camera which will be stored locally in the application sandbox. (For camera invocation, we have written native code.)
Why the architecture is planned in this way ?
One of the reasons - Any modification in the application will be handled right from the server as I mentioned that all the html and js files are centrally located on the server, Ofcourse also to skip the Apple's App submission process).
Now I am not really sure if there might be any issues with this kind of application - the issues might be because 1. Whether Apple accepts such apps ? 2. Maintenance of the Project 3. Any critics on the architectural design of the App.
I am one small developer in this project, I have these questions for you. Apologize me if I haven't put my doubts in appropriate way. Your critics and answers/tips are most welcome. Thanks..
You should use native code if possible, the performance of HTML5 apps is not very good when compared to the native apps plus the things that you can do with native apps are just worth it. Although Apple shouldn't have any problems with your apps. But As Wesley said they never really follow that consistency of the platform so they just look out of the place. Even in native apps, you might still be able to control simple aspects of your app like theme etc from a server, you just need to think ahead.

How to create a full-featured Android app for a website?

This is my website: http://www.stustu.co.uk..
I want to create an app that can pull down the listings from this website and display the entries in the form I want; enable users to manage their online accounts conveniently within the app; post new entries. Basically, a similar app to Amazon and eBay.
But I've no clue about how to query the information from the website in the app...
The website itself is WordPress based (quite simple, therefore), and my initial thought was to find some API from WordPress. I did find the official WordPress app, which comes with the source code, but it helps little as its code mainly deals with blogging.
So here's my question:
What are the normal ways a web developer would use on the server side to achieve my aim?
Is that achievable for WordPress?
If not, are there workarounds?
I'm a new self-taught developer, sorry that the question is a bit broad.
The most common approach when you're trying to communicate between an app and a website is to use a web service. Popular architectures include using REST or SOAP to communicate with your server.
This video will teach you how to use REST interface properly on your Android application, while in this link you will find that using SOAP has its disadvantages over REST especially on Android(or mobile in general).
I personally recommend using REST APIs with responses in JSON format for your web service. Twitter did the right thing with their own rest api, and you can structure yours similarly.
Other links you will be finding useful as you develop your application:
google-gson
jackson JSON
http://blogs.developerforce.com/developer-relations/2011/02/rest-api-android-awesome.html
Sorry about not answering your question about Wordpress, as I never had the opportunity to use it. For my apology, have this potato.
How much experience do you have with android? If you have none you should go find the getting started tutorials on the developer site and complete a few of them to familiarize your self with the structure of an android application before you attempt something like this.
The next thing to consider is: does your site look and act nicely on mobile? If so do you want your application to simply be a dedicated browser that pulls up your site? Or do you want to create the entire application natively? In the latter case you'll have to build (or find) some sort of APIs that allow you to tie in to the functionality of your site from within the java in the application.
My experience is mostly on Android so I cannot suggest any strategies or examples for how you'd go about setting up your APIs. But I do know if you attempt to build something that sophisticated natively on android with little experience you'll likely get frustrated early.

Android: Creating Formatted Native Android Application that takes Web Content

I'm trying to code a native android application that takes certain parts of a webpage and displays it. Basically I would want a search bar and several other things, so that I can have a clean fitted display on a mobile device. It is the same idea as the Facebook application, I am trying to create a stripped down version of a webpage.
I know how to download a full webpage using a WebView, but how can I take only certain parts of that webpage and display that instead?
EDIT: Is there any way to do this using just java and java-based api's?
(I am writing the application in native JAVA)
Best,
Aneem
It sounds to me like you effectively want to do 'web-scraping'.
I've done this by using an HTTPClient to pull a web-page which I then processed with HTMLCleaner to produce an XML document. I could then drill down through it to extract the various elements I needed (tables mostly).
You'll need to reverse-engineer the web page using the 'view source' capabilities of a web browser.
Be aware though that unless you have total control of the web page source, web-scraping is generally not a great way of producing a stable and extensible app. All it takes is for a re-design of the web page by whoever maintains it and it will potentially break your app completely forcing you to rewrite your HTML processing code.
EDIT: Actually, on the subject of the Facebook app - this isn't the same thing. There are published APIs for accessing Facebook which don't involve accessing the normal Facebook pages. The Facebook app is a 'native' Android app not a web app.
Its not sure from your question if your back-end has web api's implemented via REST, SOAP, whatever. If it does then you'd just use the necessary pieces widgets and all to implement your android application.
If it doesn't then there may not be a direct way to implement what you want. So I'd suggest looking into the back end first before looking at this aspect.
However, you might want to look at PhoneGap if you want to implement a cross platform solution.

Categories

Resources