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

No need for sunscreen in autumn? Dermatologists say

"The sun isn't that strong in autumn, so...

Top Ten World-West Traffic Tunnels in China

1 The world's longest twin-hole highway tunne...

The legendary car is no longer popular, SAIC-GM-Wuling is facing a cold winter

In the past, SAIC-GM-Wuling relied on its price a...

How does Baidu determine the conversion effect of bidding keywords?

After expanding the keywords, the enterprise SEM ...

What triggered a dramatic decline in marine biodiversity 460 million years ago?

Produced by: Science Popularization China Author:...

Why do I recommend that you really dry your quilt regularly?

Among all animal phobias, spider phobia is defini...

Why do we have multiple languages ​​in our dreams?

© Emmanuel Lafont Leviathan Press: I remembered a...

Online education app buying trends and delivery insights!

According to Adinsight product monitoring by Reyu...

Ten rules for open source success

[[151765]] Everyone wants it, and many are trying...

TikTok advertising click-through rate and high-click copywriting skills!

Recently, many advertisers have paid close attent...

Introduction to Android Face Detection

Since the introduction of the Vision library in P...