Java tutorial
/* * Copyright 2014 Nicholas Liu * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package ca.zadrox.dota2esportticker.util; import com.squareup.okhttp.OkHttpClient; import com.squareup.okhttp.Request; import java.io.IOException; import java.util.concurrent.Callable; import static ca.zadrox.dota2esportticker.util.LogUtils.LOGD; /** * Created by Acco on 11/25/2014. */ public class TeamGetter implements Callable<String> { private static final String TAG = TeamGetter.class.getSimpleName(); private static final String BASE_URL = "http://www.gosugamers.net"; private String teamUrl; public TeamGetter(String tUrl) { teamUrl = tUrl; } @Override public String call() { try { String rawHtml = new OkHttpClient().newCall(new Request.Builder().url(teamUrl).build()).execute().body() .string(); String processedHtml = rawHtml.substring( rawHtml.indexOf("<div class=\"teamImage\" style=\"background-image: url('") + 53, rawHtml.indexOf("<div class=\"teamNameHolder\">") - 11); LOGD(TAG, processedHtml); return BASE_URL + processedHtml; } catch (IOException e) { e.printStackTrace(); } return null; } }