Extract webpage content-super simple-php Tutorial

Source: Internet
Author: User
Extract webpage content --- urgent ---- super simple the website where I want to crawl content is api.94qing.com. for example, if I enter my dream, I will get the submitted content. how can I do this, no content can be obtained directly according to the API operation prompt of the website. why ??? Extract webpage content --- urgent ---- super simple
This is the website where I want to capture content ???

Share:


------ Solution --------------------
Cookie needs to be passed
Assign a special function
Function QQLite_get ($ msg, $ type = 'jm '){
$ Url = 'http: // api.94qing.com ';
$ Cookiejar = realpath('cookie.txt ');
$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_URL, $ url );
Curl_setopt ($ ch, CURLOPT_TIMEOUT, 5 );
Curl_setopt ($ ch, CURLOPT_USERAGENT, $ _ SERVER ['http _ USER_AGENT ']);
Curl_setopt ($ ch, CURLOPT_REFERER, $ url );
Curl_setopt ($ ch, CURLOPT_COOKIEJAR, $ cookiejar );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch, CURLOPT_FOLLOWLOCATION, true );
$ R = curl_exec ($ ch );

Curl_setopt ($ ch, CURLOPT_URL, "$ url? Type = $ type & msg = $ msg ");
Curl_setopt ($ ch, CURLOPT_COOKIEFILE, $ cookiejar );
$ R = curl_exec ($ ch );
Curl_close ($ ch );
Return $ r;
}

Echo QQLite_get ('Tiger'); // UTF-8 encoded Chinese
Echo QQLite_get ('elephant ');
Keywords: Tiger
The result is as follows:
1. Zhou Gongjie Meng public account
2. account: MagicStaff
3. a man dreams of a Tiger-he may encounter difficulties on the road to success.
4. women dream of Tigers-both themselves and their children will be ill.
5. dream that tigers will throw at themselves-it will be difficult.
6. dream of shooting tigers-success in career.
7. dreaming of capturing Tigers is a bad omen, and friends will take themselves as enemies.
8. dreaming that Tigers flat at other animals will worry about the situation of friends.
9. dreaming that tigers will throw on others-a major car accident may occur, but they can escape.

Keyword: Elephant
The result is as follows:
1. Zhou Gongjie Meng public account
2. account: MagicStaff
3. dream of elephants, success, reputation.
4. dreaming of riding an elephant improves social status.
5. an angry elephant rushed toward himself. only by perseverance can he make a fortune.
6. elephants with only one tooth can make a lot of money only by focusing on business.
7. dream of a treasure of elephants, and soon the difficulties will be overcome.
8. I dreamed that the elephant could beat his strong opponent by kicking and stepping on the lion.
9. dream of the wild elephant group, all efforts can be successful.
10. married women dream of playing with elephants and want to have a beautiful boy ..

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.