Android Tianying Leyue web reader source code download

Android Tianying Leyue web reader source code download

Functional classification: Entertainment

Supported platforms: Android

Operating environment: Android

Development language: Java

Development tool: Eclipse

Source code size: 15.49MB

Source code introduction

This is a web reader that uses jsoup to parse Html to obtain content. It was completed in my spare time during college. It was designed by comparing the web page elements of CSDN to parse and extract content. The core function is to use jsoup to parse. The following are related screenshots.

[Note: There are some bugs in the program]

Source code running screenshot

[[124703]] [[124704]]

[[124705]]

Source code snippet

  1. package com.weiyi.itreader.util;   
  2. import java.util.ArrayList; import java.util.List;
  3.    import org.jsoup.Jsoup;
  4. import org.jsoup.nodes.Document; import org.jsoup.nodes.Element;
  5. import org.jsoup.select.Elements;   
  6. import android.util.Log;   
  7. import com.weiyi.itreader.common.Constant; import com.weiyi.itreader.entity.ITBlog;
  8.    /**
  9. * Function: ITBlog acquisition tool, which can obtain various information of online articles by parsing HTML through URL, mainly using HTML parsing tool Jsoup *
  10. * @author moho * */  
  11. public   class ITBlogUtil { /**
  12. * Get article list *
  13. * @param url * Request URL
  14. * @return List<itblog> IT reading article list * */  
  15. public   static List<itblog> getITBlogList(String url) { List<itblog> itBlogs = new ArrayList<itblog>();
  16. try { Document doc = Jsoup.connect(url).get();
  17. Elements titles = doc.getElementsByClass( Constant.ITBLOG_TITLE_CLASS).tagName( "a" ); // Get all tag elements with class=link_title  
  18. Elements dates = doc.getElementsByClass(Constant.ITBlOG_DATE_CLASS); Elements urls = titles.select(Constant.HREF_SELECT);
  19. for ( int i = 0 ; i < titles.size(); ++i) { String blogUrl = Constant.ITBLOG_URL
  20. + urls.get(i).attributes().get( "href" ); // URL of each article   String iconUrl = getIconUrlByBlogUrl(blogUrl);
  21. ITBlog itBlog = new ITBlog(); if (iconUrl != null )
  22. itBlog.setIconUrl(iconUrl); // Set the URL of the header icon for each article   itBlog.setTilte(titles.get(i).text()); // Get the text in the a tag, that is, the article title  
  23. itBlog.setDate(dates.get(i).text()); // Get the article publication date   itBlog.setUrl(blogUrl); // Get the value of the hyperlink attribute href  
  24. itBlogs.add(itBlog); }
  25. } catch (Exception e) { e.printStackTrace();
  26. } return itBlogs;
  27. }   
  28. /** * Get article content
  29. * * @param url
  30. * Request URL * @return String IT read article content
  31. * */   public   static String getContentByURL(String url) {
  32. String content = "" ; try {
  33. Document doc = Jsoup.connect(url).get(); Element contentElement = doc
  34. .getElementById(Constant.ITBLOG_CONTENT_ID); content = contentElement.html();
  35. } catch (Exception e) { e.printStackTrace();
  36. return content; }
  37. return content; }
  38.    /**
  39. * Get the article icon, parse the img tag according to the article URL address to get the src attribute value *
  40. * @param blogUrl * The requested article URL
  41. * @return String IT reading article icon URL * */  
  42. public   static String getIconUrlByBlogUrl(String blogUrl) { String iconUrl = null ;
  43. try { Document doc = Jsoup.connect(blogUrl).get();
  44. Element contentElement = doc.getElementById (Constant.ITBlOG_CONTENT_ID); // Get the content area  
  45. Elements imgElements = contentElement.getElementsByTag( "img" ); if (imgElements.size()> 0 )
  46. iconUrl = imgElements.get( 0 ).attributes().get( "src" ); // Get UIRL, by default the URL of the first img encountered   } catch (Exception e) {
  47. e.printStackTrace(); }
  48. return iconUrl; }
  49. } </itblog></itblog></itblog></itblog>

Source code download address : http://down..com/data/1963020

<<:  Instagram-style scroll view source code download

>>:  Cocos 2d-x 2.2.6 gorgeous upgrade opens a new experience for 64-bit iOS

Recommend

Christmas and New Year's Day marketing plan (attached with download)

Christmas and New Year's Day are important fe...

Who is the suitable group for Wenchang Tower?

Friends who have read the previous introduction t...

56 Ad Monetization Terms You Must Know in 2020

According to a report from Aurora, the total onli...

The most handsome "hermit" in the Himalayas

Loading long image... Source: Qinghai Science and...

A complete guide to the three major types of community operations!

There is a very important part in private domain ...

618 sprint! How to increase brand transactions on Xiaohongshu?

The 618 promotion has entered the sprint period, ...

How to create a super user? Let’s clarify 3 points first!

Creating super users is not just a slogan, but a ...