Estoy tratando de encontrar la manera de buscar un libro por ISBN usando la API de Google Books. Necesito escribir un programa que busque un ISBN e imprima el título, autor y edición. Intenté usar List volumesList = books.volumes.list("");
, pero eso no me permitió buscar por ISBN y no vi la forma de obtener la información que necesitaba (cuando se colocaba un ISBN no tenía resultados). Lo que tengo en este momento es:Google books Búsqueda de API por ISBN
JsonFactory jsonFactory = new JacksonFactory();
final Books books = new Books(new NetHttpTransport(), jsonFactory);
List volumesList = books.volumes.list("9780262140874");
volumesList.setMaxResults((long) 2);
volumesList.setFilter("ebooks");
try
{
Volumes volumes = volumesList.execute();
for (Volume volume : volumes.getItems())
{
VolumeVolumeInfo volumeInfomation = volume.getVolumeInfo();
System.out.println("Title: " + volumeInfomation.getTitle());
System.out.println("Id: " + volume.getId());
System.out.println("Authors: " + volumeInfomation.getAuthors());
System.out.println("date published: " + volumeInfomation.getPublishedDate());
System.out.println();
}
} catch (Exception ex) {
// TODO Auto-generated catch block
System.out.println("didnt wrork "+ex.toString());
}
Si alguien tiene alguna sugerencia sobre cómo hacer esto más eficiente que me haga saber. Nuevo Código:
String titleBook="";
////////////////////////////////////////////////
try
{
BooksService booksService = new BooksService("UAH");
String isbn = "9780262140874";
URL url = new URL("http://www.google.com/books/feeds/volumes/?q=ISBN%3C" + isbn + "%3E");
VolumeQuery volumeQuery = new VolumeQuery(url);
VolumeFeed volumeFeed = booksService.query(volumeQuery, VolumeFeed.class);
VolumeEntry bookInfo=volumeFeed.getEntries().get(0);
System.out.println("Title: " + bookInfo.getTitles().get(0));
System.out.println("Id: " + bookInfo.getId());
System.out.println("Authors: " + bookInfo.getAuthors());
System.out.println("Version: " + bookInfo.getVersionId());
System.out.println("Description: "+bookInfo.getDescriptions()+"\n");
titleBook= bookInfo.getTitles().get(0).toString();
titleBook=(String) titleBook.subSequence(titleBook.indexOf("="), titleBook.length()-1);
}catch(Exception ex){System.out.println(ex.getMessage());}
/////////////////////////////////////////////////
JsonFactory jsonFactory = new JacksonFactory();
final Books books = new Books(new NetHttpTransport(), jsonFactory);
List volumesList = books.volumes.list(titleBook);
try
{
Volumes volumes = volumesList.execute();
Volume bookInfomation= volumes.getItems().get(0);
VolumeVolumeInfo volumeInfomation = bookInfomation.getVolumeInfo();
System.out.println("Title: " + volumeInfomation.getTitle());
System.out.println("Id: " + bookInfomation.getId());
System.out.println("Authors: " + volumeInfomation.getAuthors());
System.out.println("date published: " + volumeInfomation.getPublishedDate());
System.out.println();
} catch (Exception ex) {
System.out.println("didnt wrork "+ex.toString());
}
La forma en que sugirió es para HTML no Java. La forma en que lo hace BooksSample es el mismo que el anterior y no permite la búsqueda por ISBN.List volumesList = books.volumes.list (consulta) es el código que utilizaron también query es una cadena. –
La consulta utiliza una solicitud HTTP GET y recibe la respuesta en formato JSON, que es independiente del lenguaje y se usa comúnmente en Java. No hay HTML involucrado. – Chris
tenga en cuenta: https://www.googleapis.com/books/v1/volumes?q=isbn0735619670 return "totalItems": 78 colon fwd! no puede creer que no está documentado en algún lugar (al menos no lo encontré) https://www.googleapis.com/books/v1/volumes?q=isbn <0735619670> devuelve "totalItems": 511 pero https: //www.googleapis.com/books/v1/volumes?q=isbn:0735619670 realiza una búsqueda exacta y devuelve "totalItems": 1. Colon FWD! No puedo creer que no esté documentado en algún lugar (al menos no lo encontré) – masi