Advertisement
Guest User

Untitled

a guest
May 1st, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. public static Article getArticle(Element e) {
  2. Article article;
  3. String title;
  4. String description;
  5. Bitmap img=null;
  6.  
  7. title = e.getElementsByTag("title").text().replace("<![CDATA[", "").replace("]]>", "");
  8. description = e.getElementsByTag("description").text().
  9. replaceAll("[<](/)?div[^>]*[>]", "").
  10. replaceAll("[<](/)?a href[^>]*[>]", "").
  11. replaceAll("[<](/)?img src[^>]*[>]", "").
  12. replace("</a>", "");
  13.  
  14. String imgText = e.getElementsByTag("description").text();
  15.  
  16. Pattern p = Pattern.compile("src=\'(.*?)\'");
  17. Matcher m = p.matcher(imgText);
  18. if (m.find()) {
  19. String srcValue = m.group(1);
  20. InputStream input = null;
  21. try {
  22. input = new java.net.URL(srcValue).openStream();
  23. } catch (IOException e1) {
  24. e1.printStackTrace();
  25. }
  26. img = BitmapFactory.decodeStream(input);
  27. }
  28. article = new Article(title,description,img);
  29. return article;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement