通过数据分析哪些国家有钱人比较多
python爬虫吧
全部回复
仅看楼主
level 5
敏敏张487 楼主
5月24日,据福布斯报道显示,截至目前,亚马逊的杰夫·贝佐斯依然是世界首富,而lv老板暂时位居福布斯世界富豪榜第二。虽然不是第一,但是感觉奢侈品大佬有一半收入都是中国人贡献的,果然大牌还是厉害啊。
今天我们就通过爬虫实战分析下福布斯世界首富榜,看下那些国家的有钱人多,那些行业比较产有钱人。开始一个数据分析项目,首先需要做的就是get到原始数据,那我们就通过php来获取数据然后进行分析。完整代码如下:
<?php // 要访问的目标页面 $url = "http://httpbin.org/ip"; $urls = "https://httpbin.org/ip"; // 代理服务器(产品官网 http://www.16yun.cn) define("PROXY_SERVER", "tcp://t.16yun.cn:31111"); // 代理身份信息 define("PROXY_USER", "username"); define("PROXY_PASS", "password"); $proxyAuth = base64_encode(PROXY_USER . ":" . PROXY_PASS); // 设置 Proxy tunnel $tunnel = rand(1,10000); $headers = implode("\r\n", [ "Proxy-Authorization: Basic {$proxyAuth}", "Proxy-Tunnel: ${tunnel}", ]); $sniServer = parse_url($urls, PHP_URL_HOST); $options = [ "http" => [ "proxy" => PROXY_SERVER, "header" => $headers, "method" => "GET", 'request_fulluri' => true, ], 'ssl' => array( 'SNI_enabled' => true, // Disable SNI for https over http proxies 'SNI_server_name' => $sniServer ) ]; print($url); $context = stream_context_create($options); $result = file_get_contents($url, false, $context); var_dump($result); // 访问 HTTPS 页面 print($urls); $context = stream_context_create($options); $result = file_get_contents($urls, false, $context); var_dump($result);?>
2021年05月28日 08点05分 1
1