-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharq.php
81 lines (69 loc) · 2.53 KB
/
arq.php
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Importador Arquipelagos</title>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
</style>
</head>
<body>
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$page = 1;
if (isset($_GET["page"])) if ($_GET["page"]!= 0) $page = $_GET["page"];
echo $page;
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_URL,"https://www.arquipelagos.pt/wp-json/wp/v2/imagem?page=" . $page);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.A.B.C Safari/525.13");
$data = curl_exec($ch);
curl_close($ch);
$pattern = '/\{\"id\"\:.*?\]\}\}/';
preg_match_all($pattern, $data, $matches);
//echo "Tamanho:" . sizeof ($matches [0]) . "<BR>";
for ($i = 0; $i < sizeof ($matches [0]); $i++)
{
$match = $matches[0][$i];
$obj = json_decode($match, true);
//echo "Slug: " . $obj["slug"] . "<BR>";
//echo "Guid: " . utf8_decode($obj["guid"]["rendered"]) . "<BR>";
//echo "Link: " . $obj["link"] . "<BR>";
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_URL,$obj["link"]);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.A.B.C Safari/525.13");
$data1 = curl_exec($ch);
curl_close($ch);
//$data1 = utf8_decode($data1);
preg_match ('/\<img src\=\"(.*?)\" class\="card\-img mb\-2\"/', $data1, $imagem);
echo "<table><tr><td>";
echo "#" . $i;
echo "</td><td>";
echo "id: " . $obj["id"];
echo "</td></tr><tr><td>";
echo "Data: " . $obj["date"] . " (modificado em " . $obj["modified"] . ")<BR>";
echo "</td><td>";
echo "Título: " . $obj["title"]["rendered"] . "<BR>";
echo "</td></tr><tr><td>";
echo "<a href=\"" . $imagem[1] . "\">
<img src=\"" . $imagem[1] . "\" style=\"width:200px;height:auto;\" alt=\"Image\" >
</a>";
echo "</td><td>";
echo "Conteúdo: " . $obj["content"]["rendered"] . "<BR>";
echo "</td></tr></table>";
//echo utf8_decode($data1);
}
echo "<BR><BR><BR>";
echo "<a href=\"arq.php?page=1\">Primeira página</a> <a href=\"arq.php?page=" . ($page - 1) . "\">Página anterior</a> <a href=\"arq.php?page=" . ($page + 1) . "\">Página seguinte</a>";
?>
</body>
</html>