How to get information from a webpage, but not all? - android

I am retrying to retreive just the text and the image from this wiki page.
http://en.wikipedia.org/wiki/Where_the_Red_Fern_Grows
I will have a news feed, and when i item is clicked the url will be fetched. Intead of going to a the webpage through the browser, i would like to get the text and images and feed them into a textview and imageviews.

You have a couple of options.
Host a intermediary site that parses the link and passes back the data you want.
Get all of the page, and parse on the device.
Obviously parsing a huge page on the device will be far slower than parsing it on a webserver and serving just what you need.
Of course, if you are really in need of just the text and image, there is some help by using the mobile version of Wikipedia:
http://mobile.wikipedia.org
OR
http://en.m.wikipedia.org
The "mobile" version splits pages up and contains no graphics, but the "m" version is probably more along the lines of what you are looking for.
Here is the formatted page for "Where The Red Fern Grows":
http://en.m.wikipedia.org/wiki/Where_the_Red_Fern_Grows

Related

Facebook like share in android EditText

Good day.I want to create an share field like facebook.In the facebook if you insert an link it will automatically get the lets say 'short preview' of your link with an title and image.I dont think that facebook got in touch with whole wordls website databses so it gather them from databases but rather parsing the url somehow.Anyway lets imagine i have an edittext with user letting input some ulr.How can i achieve this kind of technique?By googling i did not find anything closer to what i want.
Facebook downloads the url and displays the title in the header and a few lines of text. A prominent image on the page if it finds one. You'd have to do something similar- download the url, parse the html, and grab enough info to make your preview.
Most of the websites have og(Open Graph) tags in them. Check out the Facebook Open Graphs Website to understand more about these tags. You can fetch data corresponding to these tags and that is what most social media sites and WhatsApp do to provide a preview.

Rendering (display) a part of a web page in an android application

This question is not for android programmers only , but also for whom interested in web pages design .
I would like to make an android app that renders some parts of specific web pages only (not all part of them) .
I am heard about jsoun library as a tool that does this task
My main problem is:-
How I can choose the correct link from web page's source that render some part of a web page ?.
For example let us take the famous website FORBES
How can I render the list of richest men by their name and Rank,Name net Worth,Change,Age,Source,Country of Citizenship as they appearthere excluding other parts of web page.
Here is a good example of an application that accomplishes like this task
You may have a good suggestion.
You need to screen-scrape the HTML. I'm not sure about any Android libraries for doing this, but I would build a RESTful service to return the data I needed. The service would than do the heavy lifting of scraping the webpage and converting the data to JSON to be sent back to device.
On the server side I would use a library like Beautiful Soup to do the scraping. It is easy enough to use once have it installed. You create a beautifulSoup object from the HTML and make calls like myObject.getTitle() to return the title of the HTML. You can use the tags in the HTML to drill down to the elements you want and build up a JSON object from there. Here is an image of the elements you are interested in for that list. Note the #ids on the right for that list item.
http://i.imgur.com/TMjhYvY.jpg

How to get image name from website?

I've not been successful in searching for this answer, but basically, how can I find the image file name from a website that blocks saving of the images? Normally, the url source will have the image filename and it is easily searchable.
However, some sites lets you hover over the picture and it then zooms to a larger image. The source shows,
for example,
http://example.com/pictures.aspx?ImagePath=ABCDEFGHIJ1234567989KLMNOPQRST==.....
E.g.: A random long string of code, but no .jpg or .png indicating the file name. When right clicking to save, it shows the image is blocked.
How can I get the images using Android code?
Tks
If it's not allowing them to be taken from a website, then it probably shouldn't be taken. That being said, there are a couple of options if you are the owner of the website.
If they are in a database then you can get the url address of them. Also, right clicking anywhere on the page to "View source" should get you some sort of URL of the image.
This seems more of a web service implementation issue rather than anything andriod specific. Many websites have this feature where you are not meant to retrieve information from the url.
However there should be a corresponding supported web service interface for fetching the metadata of a particular resource. If this is not supported then it's meant to be blocked.
The other trial and error sort of way is to invoke a 3rd party API like oEmbed (or Embed.ly : http://embed.ly/) that would return the metadata of the resource for which you have the URL. These services cover a wide range of websites and their resources.
You can search around in their site or find similar such services that would get you this information. Embed.ly is more of a personal preference due to its exhaustive list of supported sites.

How do you make a textview change according to an HTML document on the web

A couple of friends and I are setting up a little app business, and we are creating our general app for finding out all the latest news about our other apps. But we have a small problem.
We have a layout xml file with a table row in it. In the table row we want to show two textviews. One that says Current App version (Which we have done successfully) and the other one will show a few numbers from an HTML page which is live now.
I want to know, how would be able to get the text from the HTML document on the Web to that text view, or any other thing we could use.
(We know that the manifest will have to allow the internet)
Thanks
So in this TextView, you want to show the content of the HTML page? If this is the case, the best thing you could do is to replace the TextView with a WebView, where you could load the HTML page via its url.
If not this is the case, you can make a GET request to that HTML (i.e. using an Async Task), get the results and present them in the TextView.
Hope this helps!

RSS preview image

I would like to provide the user of my android app a preview of each article given to them by an RSS feed. Since the user enters the URL of the site with the RSS feed I don not control the source of the RSS (I must assume the page is using the RSS 2 specifications).
I know there is an <image> tag for the channel RSS feed but how do I get a preview image for each article?
In contemplating this problem I have considered parsing through the website and finding an <img> tag and using that... but the possibility of selecting an add or irrelevant image is high.
Right now I am doing all my XML parsing on a server to remove the restriction of phone processing - so parsing for the image would be easy-ish... but not fun :)
Any Ideas? (I'm thinking something like how Facebook adds thumbnails to your posts - I've looked into Facebook's open graph - but it is not widely enough distributed to be of any use)
Feed: http://www.modernizedmedia.com/blog/feed
There's no easy answer here. The RSS spec doesn't have a field for a thumbnail preview that I'm aware of.
The Media RSS spec does define a <media:thumbnails> element, but that's neither widely used nor really what you're looking for.
I'd use the <image> tag first, if it's present. If it's not, then you can scan through the article and find an <img> tag if it's present -- but you're right, it might not be the correct one. To compensate for that, you could filter out known ad sizes, then select the largest image on the page.
In all cases, you'll want to resize the image to be thumbnail sized. This is application dependent behavior.

Categories

Resources