-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsearch.php
More file actions
83 lines (58 loc) · 1.86 KB
/
search.php
File metadata and controls
83 lines (58 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
include 'simple_html_dom.php';
// Create DOM from URL or file
header('Content-Type: application/json; charset=utf-8');
header('Access-Control-Allow-Origin: *');
if(isset($_GET['page'])){$page = $_GET['page'];}else{$page = 1;}
if(isset($_GET['q'])){
$q=$_GET['q'];
$url = "https://www.pngaaa.com/search/".$q."/".$page."/";
$status = 1;
}else{$q="";$status=0;}
$html = file_get_html($url);
$idlist = [];
$suggetions = [];
//echo $feeds = $html->find('#main',0)->innertext;
foreach($html->find('.photo-grid-item') as $element){
array_push($idlist,substr($element->href,8));
}
foreach($html->find('.breadcrumbItem') as $element){
array_push($suggetions,$element->title);
}
$detais = [
'status' => $status,
'query' => $q,
'page' => $page,
'data' => $idlist,
'suggetions' => $suggetions,
];
$detais = json_encode($detais,JSON_PRETTY_PRINT);
print_r($detais);
/*
for ($x = 0; $x <= 80; $x++) {
//if(isset($_GET['page'])){$page = $_GET['page'];}else{$page = 1;}
$page = $x;
if(isset($_GET['q'])){
$q=$_GET['q'];
$url = "https://www.pngaaa.com/search/".$q."/".$page."/";
}else$q="";
$html = file_get_html($url);
$idlist = [];
//echo $feeds = $html->find('#main',0)->innertext;
echo "The number is: $x <br>";
foreach($html->find('.photo-grid-item') as $element){
array_push($idlist,substr($element->href,8));
echo substr($element->href,8) . '<br>';
}
file_put_contents("search/".$q.".".$page.".json",json_encode($idlist));
}
// Find all images
foreach($html->find('img') as $element)
echo $element->src . '<br>';
// Find all links
foreach($html->find('a') as $element)
echo $element->href . '<br>';
echo $title = $html->find('title',0)->plaintext;
print_r($title = $html->find('meta[property="og:image"]',0)) ;
*/
?>