tailieunhanh - J2ME in a Nutshell phần 5

4 điểm ảnh rộng và 2 pixel xuống, như thể hiện ở dưới cùng trong hình 5-7. Bạn có thể thấy một hình chữ nhật được rút ra chiếm một pixel mỗi bên phải và ở dưới cùng hơn là một hình chữ nhật đầy. Bạn có thể thấy điều này cho chính mình bằng cách chọn các ví dụ RectangleFills từ GraphicsMIDlet. | J2ME in a Nutshell public class BookInfo int id Used when persisting String isbn The book ISBN String title The book title int reviews Number of reviews int ranking Current ranking int lastReviews Last review count int lastRanking Last ranking We ve also added three other fields that we don t need in this example. They ll come in handy later in this chapter when I show you how to save this information in persistent storage on the mobile device. This is the information we need so how do we get it To fetch the catalog page for a book with a given ISBN we need to send a POST request to the following URL http exec obidos search-handle-form 0 We also need to supply the parameters that specify the store to be searched and the ISBN for the book. Since we are using a POST message these parameters go in the message body rather than in the URL itself. To look for ISBN 156592455X for example the message body should contain the following index books field-keywords 156592455X If you are wondering how you would know to do this you simply have to examine the HTML page that contains the search box a human user would use and work out what would be sent to the web server. Assuming that the ISBN is valid you ll get back the HTML for the book s catalog page. If you follow this process with a web browser and view the source of the returned page you ll see what to do to get the needed information from the HTML. The basic technique is to scan for a fixed sequence of characters that precedes what we need and then pull out the desired bytes by reference to those fixed points. For a book catalog page the book s title follows the string buying info its sales rank is found immediately after the string Sales Rank and the number of reviews appears after the text Based on . Once you ve worked all this out it should be simple to write the code to use HttpConnection to fetch the page and then scrape the desired details out of the HTML you get back. In fact in the J2ME .

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.