BookDepositoryCoUk.java :  » App » gone-to-get » pt » gtg » books » api » parsers » Android Open Source

Android Open Source » App » gone to get 
gone to get » pt » gtg » books » api » parsers » BookDepositoryCoUk.java
/**
 * Gone To Get Books
 * Copyright (C) 2010 Joao Eduardo Luis, Tiago Melo
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

package pt.gtg.books.api.parsers;

import pt.gtg.books.api.parsers.Book;

public class BookDepositoryCoUk extends Parser{

  String isbn = "";
  Book book = null;

  public BookDepositoryCoUk(String isbn) {
    super();
    this.isbn = isbn;
    getInfo();
  }

  public Book getBook() {
    return book;
  }

  private void getInfo() {
    String url = "http://www.bookdepository.co.uk/book/" + isbn
             + "?selectCurrency=GBP";
    
    String str = lerPagina(url);
    
    if (str == "") {
      return;
    }

    int posI, posF;

    // Price: Line 261
    posI = str.indexOf("Our price");
    posF = str.indexOf("</strong>", posI);
    if(posI == -1 || posF==-1)
      return;
    String price = str.substring(posI + 26, posF);

    book = new Book(price, url,"BookDepository.co.uk");
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.