package com.example.nick.onliner.Parser;

import android.os.AsyncTask;
import android.util.Log;

import com.example.backend.HttpClient;

public class ParseArticle extends AsyncTask<String, Void, String> {

    @Override
    protected String doInBackground(String... url) {
        String html[] = new HttpClient().getHtml(url[0]).getData();

        return getContent(html);
    }

    private String getContent(String html[]) {
        String content = "";
        for (int z = 0; z < html.length; z++) {
            if (html[z].contains("<p>")) {
                content += html[z].substring(html[z].indexOf("<p>") + 3, html[z].indexOf("</p>")) + "\n\n";
                Log.d("TAG", content);
            }
            // TODO: 02.11.2016 this condition doesn't work
            if(html[z].contains("text-align: right")) break;
        }
        return content;
    }
}
