Untitled

From Mammoth Macaw, 7 Years ago, written in Plain Text, viewed 2 times.
URL https://paste.blessuren.de/view/04897dcd Embed
Download Paste or View Raw
  1. <?php
  2.  
  3. header('Content-Type: application/json');
  4. include('simple_html_dom.php');
  5.  
  6. $btc = 0;
  7. $eth = 0;
  8. $dash = 0;
  9. $pivx = 0;
  10.  
  11. $opts = array('http'=>array('header' => "User-Agent:MyAgent/1.0\r\n"));
  12. $context = stream_context_create($opts);
  13.  
  14. // BTC
  15. $html = file_get_html('https://www.coingecko.com/en/coins/bitcoin',false,$context);
  16. foreach($html->find("span") as $span){
  17.     if($span->{'data-coin-symbol'} != false){
  18.         $btc = $span->innertext;
  19.         break;
  20.     }
  21. }
  22.  
  23. // ETH
  24. $html = file_get_html('https://www.coingecko.com/en/coins/ethereum',false,$context);
  25. foreach($html->find("span") as $span){
  26.     if($span->{'data-coin-symbol'} != false){
  27.         $eth = $span->innertext;
  28.         break;
  29.     }
  30. }
  31.  
  32. // DASH
  33. $html = file_get_html('https://www.coingecko.com/en/coins/dash',false,$context);
  34. foreach($html->find("span") as $span){
  35.     if($span->{'data-coin-symbol'} != false){
  36.         $dash = $span->innertext;
  37.         break;
  38.     }
  39. }
  40.  
  41. // PIVX
  42. $html = file_get_html('https://www.coingecko.com/en/coins/pivx',false,$context);
  43. foreach($html->find("span") as $span){
  44.     if($span->{'data-coin-symbol'} != false){
  45.         $pivx = $span->plaintext;
  46.         break;
  47.     }
  48. }
  49.  
  50. // Aktie
  51. $html = file_get_html('https://www.finanzen.net/aktien/Tesla-Aktie',false,$context);
  52. foreach($html->find("div[class=quotebox]") as $qbox){
  53.         foreach($qbox->find("div") as $div){
  54.           $tesla = trim($div->plaintext);
  55.           break;
  56.         }
  57.         break;
  58. }
  59.  
  60. echo "Tesla: ".str_replace('EUR','',$tesla)."€ BTC:$btc ETH:$eth DASH:$dash PIVX:$pivx";
  61.  
  62. ?>
  63.  

Reply to "Untitled"

Here you can reply to the paste above