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

Lu Ban, you'd better give up!

Luban ’s business is not suitable at all for smal...

Don't mess with me, I have a heat stroke...

Recently, the temperature in many parts of the co...

How to increase traffic and improve conversion?

Keywords such as short videos, content first, dat...

In the past two years, operators should force themselves to learn some Douyin

Many entrepreneurs and operation practitioners ha...

Responsive Interaction in Material Design

Responsive interactions build trust and engage us...

2017 e-commerce marketing report! What are the new ways to play?

The transaction volume on Double 11 this year hit...

Are the cotton swabs used for nucleic acid testing poisonous? Rumor!

March 28 Shanghai begins a new round of nucleic a...

The latest research confirms: exercise really can fight cancer!

Reviewer of this article: Chen Haixu, Deputy Dire...

Talk about MVVM and chained network request architecture

Preface I have been studying the architecture of ...

Station B Operation: Detailed analysis of Station B’s membership system!

On October 10, 2016, Bilibili launched the B-stat...

Xiaopeng responded to the car fire accident: caused by collision

As new energy vehicles become a major trend in th...

Product promotion: How to advertise?

A very important part of advertising is the selec...