-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnew3t.php
More file actions
91 lines (73 loc) · 2.51 KB
/
new3t.php
File metadata and controls
91 lines (73 loc) · 2.51 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
84
85
86
87
88
89
90
91
<?php
class StringV implements JsonSerializable
{
public function __construct($string)
{
$this->string=(string) $string;
}
public function jsonSerialize()
{
return $this->string;
}
}
header('Content-type: text/html; charset=utf-8');
require "phpQuery-onefile.php";
$f_json = 'InstUrls.json';
$json = file_get_contents("$f_json");
$obj = json_decode($json,true);
file_put_contents('InstData.json','[', FILE_APPEND);
foreach ($obj as $value) {
$ch = curl_init($value);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HEADER, false); // true - чтобы вывести заголовки
$html = curl_exec($ch);
curl_close($ch);
//echo $html;
/*Название*/
$url = $value;
if(!is_null($url))
{
$file = file_get_contents($url);
$doc = phpQuery::newDocument($file);
//$name = $doc->find('title')->text();
//$string = serialize($name);
//echo $string;
//file_put_contents('InstData.json', json_encode($string), FILE_APPEND);
/*Количество подписчиков*/
$metaItems = array();
foreach(pq('meta[name="description"]') as $meta) {
$value = pq($meta)->attr('content');
$metaItems = explode(' ', $value);
}
//unset($metaItems[1]);
$string = $metaItems[0];
echo $string;
} else
{
$string=NULL;
}
file_put_contents('InstData.json', json_encode($string).',', FILE_APPEND);
/*Ссылки и лайки
$data = array();
preg_match_all('/<script type="text\/javascript">window\._sharedData = \{(.*)\};<\/script>/ism', $html, $matches);
if (!empty($matches[1][0])) {
$res = json_decode('{' . $matches[1][0] . '}', true);
$media = $res['entry_data']['ProfilePage'][0]['graphql']['user']['edge_owner_to_timeline_media']['edges'];
if (!empty($media)) {
foreach ($media as $row) {
//print_r($row['node']);
$data[] = array(
'link' => $row['node']['shortcode'],
'likes' => $row['node']['edge_liked_by']['count'],
);
unset($data[1], $data[2], $data[3], $data[4], $data[5], $data[6], $data[7], $data[8], $data[9], $data[10], $data[11]);
}
}
}
$string = serialize($data);
echo $string;
file_put_contents('InstData.json', json_encode($string), FILE_APPEND); */
}
file_put_contents('InstData.json',']', FILE_APPEND);
?>