Home >Backend Development >PHP Tutorial >How do technical geeks read serials_PHP tutorial

How do technical geeks read serials_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:27:18840browse

Problem background

By the way, I am a Naruto fan, so every Wednesday, I always refresh the web page to wait for Naruto updates. Later, I also became obsessed with a serialized novel, which was updated irregularly every day, so I read and read there every day. F5 was almost broken. It doesn't matter if F5 is bad. Programmers are so busy, how can they waste their precious time in a place like this? >_048942bc06131e240eafe09aab059b36 element in the html document whose href attribute value is "/naruto/xxx".

As long as you use simple pattern matching to perform text filtering on the downloaded html code, you can get the contents of the serial directory. I think you should also imagine that using regular expressions is perfect for doing this. Taking the web page just now as an example, you can use the following regular expression to roughly filter out the serial directory:

|href="/naruto/[^"]*"|

Because different regular expressions to be used will be different, this regular expression should be configured by the user.

In PHP, you can use the pregmatchall function in PHP PCRE Functions.

Check if there is an update

This is relatively simple. As long as there are updates, the serialized content will definitely change. So just compare the content of the serial directory read each time with the content of the serial directory read last time. As long as there is a difference, it is deemed that there is an update.

As for the storage of historical data, just use a file. I used a MySQL database to do this with a bit of fuss.

Send email - PHPMailer

As someone who is not familiar with computer networks, I have a poor understanding of email protocols. After searching on Google, I found the PHPMailer library. Just refer to the SMTP example provided by this library.

I use a QQ email as the sender. What needs to be noted is that this QQ email needs to activate the SMTP service.

Effect demonstration and code download

Considering user-friendliness and versatility, we made a simple configuration page, as shown below:

The content of the reminder email received is also very simple. The content can be empty, but it is best to attach a link to the serial directory.

The code can be checked out using svn:

 svn checkout "https://svn.code.sf.net/p/roxma-proj/code/php_learn"

This is mixed with some codes that have nothing to do with the topic accumulated in the personal learning process. I believe no one will want to read it seriously. If you really want to read it, you can learn/apps/series from php learn/apps/seriesupdate_remindder/check.php to follow. It is really not recommended to read the code in detail. I think the most important content is actually the ideas mentioned in the "Technical Overview" section. (Okay, the code is too ugly, just tell me secretly and don't make it public)

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/818579.htmlTechArticleProblem background: I am a Naruto fan, so every Wednesday, I always wait for Naruto updates. Refresh the web page. Later, I also became obsessed with a serial novel, which was updated from time to time every day...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn