Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Article getArticle(Element e) {
- Article article;
- String title;
- String description;
- Bitmap img=null;
- title = e.getElementsByTag("title").text().replace("<![CDATA[", "").replace("]]>", "");
- description = e.getElementsByTag("description").text().
- replaceAll("[<](/)?div[^>]*[>]", "").
- replaceAll("[<](/)?a href[^>]*[>]", "").
- replaceAll("[<](/)?img src[^>]*[>]", "").
- replace("</a>", "");
- String imgText = e.getElementsByTag("description").text();
- Pattern p = Pattern.compile("src=\'(.*?)\'");
- Matcher m = p.matcher(imgText);
- if (m.find()) {
- String srcValue = m.group(1);
- InputStream input = null;
- try {
- input = new java.net.URL(srcValue).openStream();
- } catch (IOException e1) {
- e1.printStackTrace();
- }
- img = BitmapFactory.decodeStream(input);
- }
- article = new Article(title,description,img);
- return article;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement