Use the interface of Baidu to get beautiful pictures, and in the form of waterfall flow to show their own pages.
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 the Chrome debugging tool or Firefox Firebug tool, drag the scroll bar to the bottom, and then network to see the following request:
The parameters are as follows:
Through analysis, infer and verify the meaning of the field, Col said that the channel, tag is all the beauty, but also can be other tag (its content as shown below), PN said from the first few pictures, RN said to get how many Zhang
The return value is as follows:
Analyze the contents of the IMGs, select the attributes you want, and I'm sure I want to use Shareurl.
So we can use PHP curl according to Baidu's API to get beautiful pictures.
You can write this in PHP:
<?php
require_once './requests/library/requests.php ';
Requests::register_autoloader ();
$page = $_get[' page '];
$pageSize = ten;
$options = Array (' Host ' => ' image.baidu.com ');
$url = ' http://image.baidu.com/data/imgs?sort=0&pn= '. $page * $pageSize.
' &rn= '. $pageSize. ' &col= Belle &tag= all &tag3=&p=channel&from=1 ';
$response = Requests::get ($url, $options);
echo $response->body;
? >
The requests is a library of PHP HTTP requests, address: http://requests.ryanmccue.info/
One of the beauties can also be replaced by other channels.
After that is to show the picture, using a waterfall flow plug-in implementation.
The final code is on my GitHub, project address: Https://github.com/CraryPrimitiveMan/pretty
But the col parameter of GitHub is photography ~ ~
Of course, small partners can also be replaced by other harmonious resources, free to play under it.