1 | |
package org.paneris.bibliomania.metasearch.bol; |
2 | |
|
3 | |
import java.io.FileInputStream; |
4 | |
|
5 | |
import org.melati.util.IoUtils; |
6 | |
import org.paneris.bibliomania.metasearch.BookPageBase; |
7 | |
|
8 | |
public class BookPage extends BookPageBase { |
9 | |
|
10 | |
protected static final byte[] |
11 | 0 | bookcover = "/bookcover/".getBytes(), |
12 | 0 | isbncue = "ISBN".getBytes(), |
13 | 0 | price = "price".getBytes(); |
14 | |
|
15 | |
public BookPage(byte[] text) { |
16 | 0 | super(text); |
17 | |
try { |
18 | 0 | skipTo(bookcover); |
19 | 0 | imageURL = quotedStringFromBack(bookcover.length); |
20 | |
} |
21 | 0 | catch (Exception e) { |
22 | 0 | here = 0; |
23 | 0 | skipTo(price); |
24 | 0 | } |
25 | |
|
26 | |
try { |
27 | 0 | skipTo(isbncue); |
28 | 0 | skipSpace(); |
29 | 0 | isbn = digits(); |
30 | |
} |
31 | 0 | catch (ParseException e) { |
32 | |
} |
33 | 0 | catch (ArrayIndexOutOfBoundsException e) { |
34 | 0 | } |
35 | |
|
36 | 0 | this.text = null; |
37 | 0 | } |
38 | |
|
39 | |
public static void main(String[] args) throws Exception { |
40 | 0 | BookPage p = |
41 | |
new BookPage(IoUtils.slurp(new FileInputStream(args[0]), 1000)); |
42 | 0 | System.out.println(p.imageURL); |
43 | 0 | System.out.println(p.isbn); |
44 | 0 | } |
45 | |
} |