Home >Backend Development >PHP Tutorial >Get the backend code for joke data on the joke collection website, get the joke backend code_PHP tutorial
I recently made an app to get the data on the joke collection website, in order to facilitate development. I first used PHP to preprocess the data
The code is as follows
<?php include_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\">") + 23; $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,"上一篇:<a"); if ($begin != false) { $begin += 27; $end = stripos($html,"\"",$begin); $this->urlNext = substr($html, $begin, $end - $begin); } $begin = stripos($html,"下一篇:<a"); if ($begin != false) { $begin = $begin + 27; $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\">") + 42; $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; } }
1. A bear came over/came prepared (BEAR came)
2. The eleventh book/incredible (BOOK11)
4. Xiaoyu said to Xiaoming that her father was impotent/can’t stop ( Jade dad can’t)
5. The sheep stopped breathing/feeling proud (the sheep didn’t exhale)
6. The mobile phone cannot be dropped into the toilet/the machine cannot be lost (wet)
7. The dog will not cross the single-plank bridge. Called / photographic memory (passing the tree without barking)
8. The bee stopped on the calendar / the wind was beautiful (the bee and the calendar)
10. Painters like to draw thick ropes but not thin ropes / Superb (a thick rope enters the painting)
13. There are ten sheep, nine squatting in the sheep pen, and one squatting in the pig pen/cadence (one sheep squats wrong)
14. The sheep calls the eagle, and the eagle answers Pick up the phone and say "Hello"/Yang Feng Yin Yin (Sheep PHONE Eagle "Hello")
15. Turn the hat inside out before wearing it/Put it on with the crown and Li wearing it (wear it with the dirty crown inside)
16. Ten men watch five women taking a bath /Colorful
17. Who doesn’t have a phone? /天衣(天衣狠phone)
18. Who knows the birds best? / Frightened Bird (Frightened Bird) Pidgeot
22. How to make a sparrow quiet? /Squeeze it (squeeze the bird silently)
23. Which kind of snake has many mouths? / Chatterbox (snake)
25. What medicine is not poisonous? /Yam
26. Why is “seven up and eight down”/seven above eight? Because eight is under seven
27. Which kind of snake has the strongest vitality? /Three-Inch Tongue (Snake)
28. Why is there only the tip of the iceberg? /The other corner was broken off by the Titanic
Telling jokes. . .
Um, I think so too, okay, you should go and watch the skits or listen to the radio first
Ha, my space is full of jokes, you might as well go and check it out
There are more in the space, haha.
1. Once when I was waiting for a bus, a BMW drove by. An expert next to me said to the people next to him: "Look, the car that just passed by is an IBM."
2. I A friend was an intern at China Unicom. One day, an old man came up to him and said, "Can you apply for a mobile card for me?" Then my friend said without looking up, "Master, someone is here to cause trouble." ! ”
3. My colleague was probably nervous when he went to see a client, so he said, “Hello, Mr. Liu, what’s your name?”
4. The geography teacher used to be a man. He was very violent. He would punch anyone who spoke or was distracted, but he would not hit girls. There was a new girl who didn’t know and thought that men and women were equal. Once she was in class. I was secretly reading comics and was discovered by my geography teacher. When I walked up to her, without saying anything, the female classmate turned pale with fright and shouted: It's indecent. Our geography teacher, Waterfall Khan.
5. My classmate said: I put too much washing powder. Another asked: What? Does your brother have too many wives?
6. One day, the wind was strong and the bicycle fell into a row. I heard a classmate say while holding the bicycle: Whose Mercedes-Benz ran over my BMW?
7. I called my boyfriend in the dormitory before, but he didn’t answer the phone. I was a little embarrassed, so I made up a random name and said, "Is XX here?" I just wanted to pretend I was looking for the wrong person. ~~The other party hesitated for a moment and said, "Wait a minute, I'll call you." I fainted at that time! I was so scared that I hung up the phone. Later I asked my boyfriend and he said that a boy in the dormitory opposite them called me the name I made up.
8. Last time I was abroad, I saw a handsome guy selling pastries on the street. My friend and I said he looked like Elvis Presley while we were buying. He heard us talking about him and asked us what we were talking about. I After thinking for a long time: "kingofmiaomiao (meow meow)."
9. The girlfriend in the dormitory called the netizen and the other end was obviously very excited: Hello, I am Wang Xiaoliang, who do you think I am? I can't afford to faint...
10. I learned a sentence from a friend: I'll give you ten words - get as far away as you can. I remember the first time he said this to a group of us, I saw everyone counting on their fingers to see if it was ten words... What's even more awesome is that I said this sentence to n friends, basically More than 90% of the people will hesitate for a moment, say silently or move their fingers slightly, and then say with a smile on their face, "Damn, it really is only ten words." Tried and true, haha!
(It’s so cold, it’s winter now, it’s so harmful...)
One day, Eggplant was walking on the street when he suddenly sneezed very loudly. It wiped its nose and said angrily: "Damn it! Someone took a group photo again!"
There are 30 frogs in a pool and only one of them is wearing underpants. Why? (Because he was a bather!)
There was a pig, and he walked and walked, and walked to England. What did he become?----Pig.
Class teacher During a spot check on memorizing the text, piglets, puppies, and kittens all raised their hands. Who will the teacher call? - Puppy, because Wangwang Senbei.
Butterfly, ant, spider, centipede, they work together, in the end, which one does not get paid? - Centipede, because he has no merit.
The elephant in the zoo has the longest trunk, so who is the second longest? - the baby elephant.
Which fruit has the worst eyesight? - Mango.
Which two fruits have mobile phones? - Carrots and greens, each has its own phone.
If there is a car, the driver is a prince and the passenger is a princess, whose car does it belong to? - If
metal, wood, water, fire and earth, whose legs are longer? ——Ham Sausage
The cobra went on a date with the elephant. After some greetings, he said, "Come on if you want. You're being polite for holding such a big pig."
I think, If only I had a little more humility, I would be a perfect person.
One day, Mung Bean broke up with his girlfriend. He was very sad, so he kept crying and crying and crying... and finally... it sprouted. ~~~
Two jellyfish collided at the beach. Jellyfish A: "What are you doing! You don't have eyes when you swim!" Jellyfish B: "What are eyes?" Jellyfish A: "I I don’t know, he scolded me like this when I bumped into someone last time.” Jellyfish B: “Oh! That’s right!”
In elementary school science class, the teacher told us that if we tap on the knee, it will happen. Knee jerk reflex. When I got home, I took a hammer and hit my dad's knee. As a result, my dad stood up and kicked me. It turns out that the teacher was right!
If one day I...the rest of the text>>