Get the background code of joke data for jokes collection website

Source: Internet
Author: User

Recently made an app to get data on jokes collection sites for easy development. I first preprocessed the data with PHP.

The code is as follows

<?phpinclude_once ("writelog.php"), class Joke{var $jokeText = "", var $urlNext = "", var $urlPrv = "", var $urlBase = "http ://wap.jokeji.cn/"; function __construct () {}function getcontent ($url) {MyLog (" Url.log ", $url); $html = file_get_ Contents (Iconv ("gb2312", "UTF-8", $url)), $begin = Stripos ($html, "<div class=\" joketxt\ ">") +; $end = Stripos ($ HTML, "<script", $begin); $r = substr ($html, $begin, $end-$begin); $r = Str_ireplace ("<p>", "", $r); $r = Str_ Ireplace ("</p>", "", $r); $r = Str_ireplace ("<br>", "\ r \ n", $r); $this->joketext = $r; $begin = Stripos ($ HTML, "previous: <a"), if ($begin! = False) {$begin + = +, $end = Stripos ($html, "\" ", $begin); $this->urlnext = substr ($html, $begin, $end-$begin);} $begin = Stripos ($html, "Next: <a"), if ($begin! = False) {$begin = $begin +; $end = Stripos ($html, "\" ", $begin); $this-&gt ; URLPRV = substr ($html, $begin, $end-$begin);}} function Getfirstlink () {$html = file_get_contents ($this->urlbase); $begin = Stripos ($html, "<div class=\" list">") + $end = Stripos ($html, "\" ", $begin); $r = substr ($html, $begin, $end-$begin); return $r;} function Getjoke ($u) {if ($u = = "") {$url = $this->urlbase. $this->getfirstlink ();} else{$url = $this->urlbase.urlencode ($u);} $this->getcontent ($url); $joke = Array (); $joke ["content"] = $this->joketext; $joke ["next] = $this->urlnext;$ Joke["previous"] = $this->urlprv;return $joke;}}

Get the background code of joke data of joke set website

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.