-
Notifications
You must be signed in to change notification settings - Fork 0
/
ideasfeed.php
36 lines (29 loc) · 879 Bytes
/
ideasfeed.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
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'on');
require "vendor/autoload.php";
use Goutte\Client;
$client = new Client();
$crawler = $client->request('GET', 'https://in.tradingview.com/ideas/');
$list=array();
$crawler->filter('a.tv-widget-idea__title')->each(function ($node) use (&$list) {
// print $node->text()."<br>";
$list['name'][]=trim($node->text());
$list['url'][]=trim('https://in.tradingview.com'.$node->attr('href'));
});
$crawler->filter('.tv-widget-idea__cover')->each(function ($node) use (&$list) {
$list['img'][]=trim($node->attr('src'));
});
$refinelist=array();
$xc=0;
foreach($list['img'] as $img){
if($xc<20){
$refinelist['img'][]=$img;
$refinelist['name'][]=$list['name'][$xc];
$refinelist['url'][]=$list['url'][$xc];
}
$xc++;
}
header('Content-type: application/json');
echo json_encode(array('data'=>$refinelist));
?>