is that possible in Android to go though whatever link and get main content from that page(f.e.text) or whatever i want to get? If yes, how i can realize that?
There is couple ways to get data from websites.
First and maybe the most popular way is parsing RSS feed from webiste. Java and Android are providing couple parsers and ways to parse xml or in this case RSS Feed. You can take a look in this examples:
https://developer.android.com/samples/BasicSyncAdapter/src/com.example.android.basicsyncadapter/net/FeedParser.html
https://www.tutorialspoint.com/android/android_rss_reader.htm
Second way is getting needed informations from API if it is provided from webiste and offten that API will be in JSON format. For example https://openweathermap.org/ will return JSON file filled with informations of weather which you can pares into your app. Also Android and Java are providing couple ways to get informations from JSON format. You can take a look on this one:
http://www.androidhive.info/2012/01/android-json-parsing-tutorial/
Third you can use support library called Jsoup for parsing HTML from particular webiste/s. You can find examples how to parse HTML on their offical webiste: https://jsoup.org/
Maybe there is more ways certanly you should look up for them.
Related
I want to add a tab to my Android App that pulls information from the web. The first tab should be a list of the most popular TV Shows on IMDB (http://www.imdb.com/search/title?at=0&count=100&sort=moviemeter&title_type=tv_series,mini_series) for example.
What would be my first steps? How can I parse this data and then reuse (the title for example) in my app? I am not really familiar with API and parsing data, so I need some guidance towards the right direction.
You can try Jsoup for parsing html data.
Include jsoup in your app by configuring the build path.
Jsoup is so easy to use and parse data
The jsoup website itself is very helpful for its usage.
For easy parsing of the website first understand the source of site and use the Online Jsoup Parser
I am trying to develop an app to get the RSS feeds from http://xxx.xxx.com/xxxxxblog .
Can someone help me with the HTML parsing to get the feeds?
You can try JSoup to parse the HTML.
It is very simple to use and well documented, you should not have too much trouble parsing your page.
You can find how to do that from this page
http://jsoup.org/cookbook/extracting-data/selector-syntax
It uses different html tag to parse data between that tag.
The feeds on this web page seem clearly delimited by <dc:subject> tag.
As you only need to get the feeds, the shortest way may be better to get the feed boundaries with regular expression that would also capture the header (something like <dc:subject>(.*?)</dc:subject>). Read line by line, once you detect the expression - this is the start of the feed. Maybe it is philosophically not the most right way and we should parse all HTML instead but why to run unnecessary code ...
There is no lack of Java built-in parsers either, starting from Java's built in HTML parser and continuing to various alternative libraries that in some cases may fit better, some also suggest to use XML parser (XPath). Various solutions are discussed here.
please try
Use this example code to create RSS reader that is actually can handle namespace extensions
https://github.com/dodyg/AndroidRivers/blob/master/src/com/silverkeytech/android_rivers/xml/RssParser.kt
The library underlying this code is this https://github.com/thebuzzmedia/simple-java-xml-parser.
It works very well in Android as well.
I have read the example for Rss Parsing from the ibm site.(http://www.ibm.com/developerworks/opensource/library/x-android/).
In this example,the rss are shown in a listview and then,if you press one announcement you can see it in the web browser of the device.How could i see them in the app,with no use of the device browser?
Thanks a lot
Create a layout with a WebView then load the URL from each "announcement" using WebView.loadUrl.
I'm a little confused but you seem to have answered your own question.
You say you don't want to use the web browser on the device but the example in your question doesn't use the browser. It does exactly what you're asking for.
The idea is that you download the html from the website and then use the parser to break it up into separate "announcements" and store them in list view items in your program.
I have done a bit of this type of thing myself in android. I used jsoup java library, which makes breaking the html into the bits you want to display really easy.
If you want some more help I can give you an example of an app I made that pulls movie times from google.com/movies as an example. here are links to the classes where I did the html download and parse:
ScreenScraper.java
HtmlParser.java
I am looking into developing an App that will convert a website into more readable data for an android app. I am at university and have an online notice board which can be viewed on the web but if possible I would like to transfer this into an app on android to make it more easy to read on mobile devices.
What I thinking is that the app would go to the website where the notice board is held and read in the html code to display each notice in a list adapter view. Each notice is within its own div so I assume I could use that to split each notice up into its own button on the list adapter view. Is this possible and if so how I can go about doing this. I have tried google for an answer but I have not yet found a solution to this problem.
Thanks for your help
It seems overly complicated to me. I wouldn't handle all that using Android. I'd crawl the data on a machine (server) and then I'd convert all needed data to JSON and have the Android (client) fetch the data using a simple JSON parser.
In my opinion that would be the easiest solution if you don't have access to the server the website is hosted on to get it generate a JSON feed for you directly.
EDIT: In answer to your comment Boardy.
Here is the official website of the JSON project in order to get an understanding of what it is. Then if you have access to the webserver providing that page (I assume it is a PHP based site) and want to modify or add the functionality of providing a JSON feed then you should also take a look at the PHP JSON documentation.
To parse JSON on Android check out this SO question and also don't forget to take a look at the official Android documentation on their JSON implementation.
I want to show feeds from a blog in a listview. It would be really help if you guys can suggest some tutorials or how to do it?
thanks in adv.
I can point you in the right direction, using standard Android SDK components.
Your solution will consist of several pieces - an HTTP downloader, an RSS parser (presumably the blogs have public RSS feeds), a ListAdaptor, and your ListView.
Firstly, you need to grab the RSS file from the blog. There are a bunch of ways to do this, I'd suggest using HttpClient and HttpGet.
Next, you'll need to parse the RSS file you downloaded. For this, you can use XMLReader. Writing a good RSS parser is probably the trickiest bit!
Now you've got your data parsed, store it in a list and write a ListAdaptor.
Hook the ListAdaptor upto your ListView using setAdaptor and you're good to go.
If this all sounds a bit complicated, there are various Java RSS libraries that'll perform steps 1 and 2 for you.
You may also want to take a look at the source code of android-rss, and give IBM's XML article a good read!