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-> ; 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