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

A new problem for mankind: the "sin" and "punishment" of space activities

With the development of aerospace technology and ...

Baidu Information Flow Promotion Product Manual

As user behavior undergoes tremendous changes in ...

Guixianbei University Sisters Xueba Parents Class for All Ages

Introduction to the resources of the all-age pare...

Script design for selling courses through Tik Tok live streaming!

Oral English classes, psychology classes, financi...

The old man who is addicted to picking up garbage may be struggling with illness

From another perspective, collecting garbage may ...

How to promote a new App to get the first batch of seed users?

When it comes to promotion , the first step that ...

Do you know how to solve the 3 most important equations in APP operation?

During APP operation , there are a large number o...

Product and operation analysis of the popular social product SOUL!

Everyone says that 2018 is a cold winter for the ...

One article to understand the bidding mechanism of advertising promotion!

On a media platform, there will be tens of thousa...