In the new project, we can simply update novels with WeChat.

Source: Internet
Author: User

Implementation principle: 1. Monitor the directory page of the novel at intervals to determine whether there are new chapters (I compared the number of chapters obtained each time. If this acquisition is more than the previous one, is updated)

2. Send the new chapter as an email to your mailbox.

3. Receive the email notification

Paste the key part of the Code: Pay attention to the use of the Class Library HtmlAgilityPack, you can search for it to download

 

Retrieve the novel directory

/// <Summary> /// obtain the directory /// </summary> /// <param name = "url"> novel page Directory page </param> /// <param name = "xPath"> </param> /// <param name = "Encoding"> </param> /// <returns> </returns> public Dictionary <string, string> List (string url, string xPath, string Encoding) {using (WebClient client = new WebClient () {Dictionary <string, string> result = new Dictionary <string, string> (); string html = null; try {; client. Headers. add ("User-Agent", "Baiduspider"); client. encoding = System. text. ASCIIEncoding. getEncoding (Encoding); html = client. downloadString (url);} catch (Exception ex) {Log. writeError (string. format ("Class: NovelList, method: List, get webpage {0}, exception information: {1}", url, ex. message);} HtmlDocument doc = new HtmlDocument (); doc. loadHtml (html); HtmlNode rootNode = doc. documentNode; HtmlNodeCollection nodeList = rootNode. se LectNodes (xPath); try {foreach (var item in nodeList) {if (! String. IsNullOrWhiteSpace (item. InnerText) & item. InnerText! = "") {If (! Result. containsKey (item. innerText) {result. add (item. innerText, item. firstChild. attributes ["href"]. value) ;}}} catch (Exception ex) {Log. writeError (string. format ("Class: NovelList, method: List, foreach, get webpage url: {0} exception information: {1}", url, ex. message);} return result ;}}

  

Obtain the code of a specific chapter:

/// <Summary> /// obtain the specific content of the chapter /// </summary> /// <param name = "url"> url of the novel chapter </param> /// <param name = "xPath"> XPath </param> /// <param name = "Encoding"> Encoding </param> /// <returns> </ returns> public string Content (string url, string xPath, string Encoding) {using (WebClient client = new WebClient () {string html = string. empty; client. headers. add ("User-Agent", "Baiduspider"); client. encoding = ASCIIEncoding. getEncoding (Encoding); html = client. downloadString (url); HtmlDocument doc = new HtmlDocument (); doc. loadHtml (html); HtmlNode node = doc. documentNode. selectSingleNode (xPath); foreach (var item in node. descendants ("script "). toArray () {item. remove ();} foreach (var item in node. descendants ("style "). toArray () {item. remove ();} return node. innerHtml ;}}

  

 

 

If you want to see the results, paste the tutorials I wrote to my friends here.

 

I believe that many mobile phones are installed. After all, they are a powerful tool in the gaming industry. We like those who read novels. Waiting for the novel to be updated can be said to be a very painful task. Thinking about the story of the novel, we are anxiously refreshing the webpage and reading whether the novel has been updated. Sometimes, when I work half of my work, I will see if the novel is updated.

Today we will introduce how to use the latest chapter of the novel. First, I will introduce the principle: I can receive emails from my mailbox. If I can send the latest chapter of the novel as an email, I can read the novel. The question is, how can I send the latest chapter of the novel as an email? Fortunately, a website provides this service, taking "GOCE" as an example.

1

 

2

3

4 The lulua00@126.com is added to the whitelist. To

 

Set the lulua00@126.com to add to the whitelist

 

5

6

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.