Parsing plain text from webpage - android

It's the very first time for me asking question on this forum, so hope that everyone won't be too strict.
This semester I've been doing Project and I decided to make android application that will be able to parse articles from websites(not one, but many) and save it in text file or SQLite Database. I've been doing this for already 5 months and I really don't know how can I get particular plain text from webpage without getting unrelated to particular article stuff, such as adds etc.
Through this forum I found out how I can parse data from one website using Jsoup(I'm using one in my Project). And I thought it might work with multiple websites as well, but since many websites using different html tags to represent content of certain article, I couldn't find any common parameters that can be used.
I'm not sure, but I think I saw somebody on this forum said this kind of thing is impossible, but then how we can explain existence of such kind of apps like Pocket(Former Read it Later), Instapaper etc. These apps are doing what ultimately I want my app to do.
So can anybody give any suggestions about what can I do about it? Thanks.

I'm not sure whether it's going to show whole story, but here is the code:
doc = Jsoup.connect("http://"+URLField.getText().toString()+"").get();
// get page title
title = doc.title();
doc = new Cleaner(Whitelist.none()).clean(doc);
Here I'm simply using Jsoup library and its Cleaner class, but I get a lot of text that I don't want to appear. I wanted to post image to make it clear(what I want), but this forum doesn't let me do that.

Related

Want my app to export data into html file

It's late and my brain can't even think of the proper things to search for to find the help I need.
Here's what I'm aiming for:
My app takes in a bunch of data from the user. Specifically sizes for windows and doors around a house. My app takes all that data and determines how much material is required, etc.
Here's where I'm stuck:
What I'd like to do is turn that all into a fancy looking report and offer the user the ability to print it. I figured the easiest way to do that would be to generate a report using HTML (or PDF) and have it open up in a web browser, which already has print capabilities.
Can anyone tell me if this seems like a good strategy for what I'm trying accomplish? And if so, point me in the right direction (or to the exact same questions that's already been answered somewhere on this forum).
Thanks.

How to make an app submit info into a webform

I was trying to write an android app to help people do easier searches on multiple websites like craiglist, ebay ..etc
I am not sure where really to start from, or the name of the technology I would be using. To make it more accurate question, these websites are all forms based that you either post stuffs or retreive stuffs through searching. How can I make my android app actually in which it will ask the user for a item name (that part I know) and then send item name to say craiglist so it gets the results back?
I was thinking of copying the url that is displayed on my broswer when I click search on any of the website and using the same link with string manipulation to include whats needed.
Is this correct? Any other ideas are I know? I am kinda all over the place, but I need a starting point.
Some sites might expose a public API for you to connect with, but that's site specific.
Sites that do not expose such a system can be "scraped", which means you're using string manipulation (as you mentioned) to parse our the data you're after.
Both ways require basic knowledge on how to perform HTTP operations, there are several ways to do this but the easiest way it to use the HttpURLConnection class as described in various tutorials on the web.
Googling for "android http GET POST tutorial" should point you in the right way to get started with your adventure :)

Querying the time using Google Search Results

This one is puzzling me...
For my Android application I want to be able to return the current time in any location the user requests (right down to city level). The request itself comes from a voice command, so I cannot use alternative methods.
The most obvious way (so I thought) was to query Google, but I need your brains to help me solve how to extract the data I want please!
In Google, query:
"What's the time in China"
You should see a 'widget' at the top displaying the answer nicely. View the page source and search on 'China' and it's there - I thought great, this is going to be easy!
But...
"What's the time in London"
Although the display in Google appears the same, there is no result for 'London' when searching the source HTML...?
Using Google Chrome, I inspect the element of the 'widget' and can then view the contents I wish to extract in all cases.
So, my questions is firstly, am I missing something obvious (Google don't want us to be able to do this for example)? Or is there a way to 'force' the result to be in the HTML by structuring the query perhaps?
Secondly, is there a way to access the specific 'element container' and return the results to my Android Application?
I thank you in advance...
You should really use an API instead of parsing html.
I guess there are many many API which will give you the time in a given city.
http://www.worldweatheronline.com/time-zone-api.aspx for example (havnt tried it myself)
If you still want to extract data from the google result (which is html), check for html parsers like in this post : Parse HTML in Android

Fill Form Data in Android

I am new to Android development. Using android, I am trying to go to a certain website which is not under my control(developed by someone else and I can't change), fill the data in form fields.
Using WebView control, i am able to load the given URL. But i am stuck with sending/filling data to form fields.
How do i proceed with that?
You probobly need to do somthing like in this question.
You should realy check with the person responsible for the website. If you can get a bit of co-operation then they are less likely to change the form on you and break your code. I have a similar senario and the other party is very happy and will at least inform me before any major changes occure.

Searching Activities for text?

I am very new to Android development. I'm developing an application (if you want to call it that.) that really just displays static text. It is a guide for people to use at work. All the text is static. I've developed many activities that have static text on them.
I'd like to build search functionality in so people don't have to browse using a table of contents. I know search in android is much more powerful and can search SQLite db & etc, but can it just search various activities in your app? Does anyone know if this is possible and if so, could you point me in the right direction? Obviously if you start googling for "search activities for tet", you get a lot of information on "Search Activities." So as a new Android developer, it is a little frustrating.
I appreciate any help people can give, even if alternatives to what I'm trying to do!
Since the activities simply contain some text, you already have the text available in one form or another (even if they are just strings compiled into the application). I would recommend beginning with a search of these strings, or the data source that you are using to build the activities.
Let's assume, for the sake of a brief description, that your text is stored in an array of strings; then you can search these strings to determine which chapter contains the text the user is searching for. If these chapters were defined in resource files, you might open and search the resource files during the operation. You will have to implement the specific searching, however, yourself.
There is no automatic index that Android can provide which simply searches through the activities you've defined; the content of any application or screen is too dynamic to index.

Categories

Resources