Home > Backend Development > PHP Tutorial > Implementation of beauty picture wall, implementation of beauty picture wall_PHP tutorial

Implementation of beauty picture wall, implementation of beauty picture wall_PHP tutorial

WBOY
Release: 2016-07-13 10:20:07
Original
4375 people have browsed it

Implementation of beauty picture wall, implementation of beauty picture wall

Use Baidu’s interface to obtain beauty pictures, and display them on your own page in the form of waterfall flow.

github project address: https://github.com/CraryPrimitiveMan/pretty

The final effect is as follows:

Click on the beauty channel of Baidu Pictures, http://image.baidu.com/channel?c=%E7%BE%8E%E5%A5%B3#%E7%BE%8E%E5%A5%B3

Open Chrome's debugging tool or Firefox's firebug tool, drag the scroll bar to the bottom, and you can see the following request in the network:

The parameters are as follows:

Through analysis, we inferred and verified the meaning of the fields. col means channel, tag means all beauties, or other tags (the content is as shown below), pn means which picture to start from, and rn means How many pictures to get

The return value is as follows:

Analyze the content in imgs and select the attributes you want. I am sure to use shareUrl.

In this way, we can use PHP's Curl to obtain pictures of beautiful women based on Baidu's API.

You can write this in php:

<?<span>php
</span><span>require_once</span> './Requests/library/Requests.php'<span>;
Requests</span>::<span>register_autoloader();
</span><span>$page</span> = <span>$_GET</span>['page'<span>];
</span><span>$pageSize</span> = 10<span>;
</span><span>$options</span> = <span>array</span>('Host'=>'image.baidu.com'<span>);
</span><span>$url</span> = 'http://image.baidu.com/data/imgs?sort=0&pn=' . <span>$page</span> * <span>$pageSize</span> . 
        '&rn=' . <span>$pageSize</span> . '&col=美女&tag=全部&tag3=&p=channel&from=1'<span>;
</span><span>$response</span> = Requests::get(<span>$url</span>, <span>$options</span><span>);
</span><span>echo</span> <span>$response</span>-><span>body;
</span>?>
Copy after login

The Requests is a PHP HTTP request library, address: http://requests.ryanmccue.info/

The beauties can also be replaced with other channels.

The next step is to display the pictures, which is implemented using a waterfall plug-in.

The final code is placed on my Github, project address: https://github.com/CraryPrimitiveMan/pretty

It’s just that the parameters of col on github are photography~~

Recommend a beauty picture wallpaper

The types of wallpaper include: PVC wallpaper, cloth-based PVC wallpaper, pure paper wallpaper, non-woven wallpaper, diatomite wallpaper, velvet fiber wallpaper, etc. This is what I heard from the shopping guide and decoration master when I was renovating my home, haha . When I was renovating my home, I used Ruibao brand wallpaper as the background. It is made of velvet fiber made of large lilies. It feels soft and has a strong three-dimensional effect. My family likes it very much.

Beauty pictures, have you planted a wall? ?

I am holding my head and waiting for the outcome of something scary.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/868463.htmlTechArticleImplementation of beauty picture wall. The implementation of beauty picture wall uses Baidu’s interface to obtain beauty pictures and displays them in the form of waterfall flow. to your own page. Github project address: https://githu...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template