daily pastebin goal
53%
SHARE
TWEET

Untitled

a guest Feb 4th, 2016 112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3.  * Created by JetBrains PhpStorm.
  4.  * User: hexxy
  5.  * Date: 2/3/16
  6.  * Time: 9:43 PM
  7.  * To change this template use File | Settings | File Templates.
  8.  */
  9.  
  10.  
  11. function initCurl($Url){
  12.     $ch = curl_init();
  13.     curl_setopt($ch, CURLOPT_URL, $Url);
  14.     curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . '/cookie.txt');
  15.  
  16.     $headers = [
  17.         'Host: olymptrade.com',
  18.         'Connection: keep-alive',
  19.         'Cache-Control: max-age=0',
  20.         'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
  21.         'Upgrade-Insecure-Requests: 1',
  22.         'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36',
  23.         'Accept-Language: en-US,en;q=0.8,ru;q=0.6',
  24.         'Cookie: jv_enter_ts_5hPq7ITZ0Q=1451336079735; jv_visits_count_5hPq7ITZ0Q=1; jv_email_5hPq7ITZ0Q=hexxyg%40gmail.com; jv_client_name_5hPq7ITZ0Q=Andrey; _ym_uid=1451336522319185580; jv_client_id_5hPq7ITZ0Q=192256.3L0krHeZgxrO2a9%2Bk8yAHno2YLC4BXMIPbX2cjVpjK0; jv_pages_count_5hPq7ITZ0Q=15; jv_gui_state_5hPq7ITZ0Q=WIDGET; ref_c=olymp; ref=olymp; land=olymp; checked=1; dguid=_539326; _ym_isad=1; props[deal_oneClick]=true; props[chart_periodl]=1; props[chart_format]=line; _gat=1; session=0df246u3d70l253046ducjaoj5; _ga=GA1.2.856487965.1451336077'
  25.     ];
  26.     curl_setopt($ch, CURLOPT_HEADER, false);
  27.     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  28.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  29.     curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  30.     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  31.  
  32.     return $ch;
  33. }
  34.  
  35. function setPostData($curl, $data)
  36. {
  37.     curl_setopt($curl, CURLOPT_POST, true);
  38.     curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
  39.  
  40. }
  41.  
  42. function getResponse($curl)
  43. {
  44.     $output = curl_exec($curl);
  45.     return $output;
  46. }
  47.  
  48. /*
  49. // входим на сайт
  50. $curl = initCurl('https://olymptrade.com');
  51. $data = getResponse($curl);
  52.  
  53. curl_setopt($curl, CURLOPT_URL, 'https://olymptrade.com/user/login?_=1454526316.06');
  54. // логин
  55. $postData = urlencode('email=hexxyg@gmail.com&password=astharot&remember=true');
  56. setPostData($curl, $postData);
  57.  
  58. $data = getResponse($curl);
  59.  
  60. // страница платформы
  61. curl_setopt($curl, CURLOPT_URL, 'https://olymptrade.com/platform');
  62. curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
  63. curl_setopt($curl, CURLOPT_POST, false);
  64. curl_setopt($curl, CURLOPT_POSTFIELDS, null);
  65. $data = getResponse($curl);
  66.  
  67. // переключаемся на демо-счет
  68. curl_setopt($curl, CURLOPT_URL, 'https://olymptrade.com/user/playdemo?_=1454527045.039');
  69. $data = getResponse($curl);
  70.  
  71. // открываем сделку
  72. curl_setopt($curl, CURLOPT_URL, 'https://olymptrade.com/deal/open?amount=100&duration=60&dir=up&pair=EURUSD&source=platform');
  73. $data = getResponse($curl);
  74. echo $data;
  75.  
  76. */
  77.  
  78. $curl = initCurl('https://webrates.truefx.com/rates/connect.html?l=n&t=250&query=0.505130654710389');
  79. $data = getResponse($curl);
  80.  
  81. function parseIt($valueStr, $tokenLength, $tokenCount)
  82. {
  83.     $tokens = [];
  84.     $start = 0;
  85.     $end = $start+$tokenLength;
  86.     $token = null;
  87.     for($index =0; $index < $tokenCount; $index++) {
  88.         $tokens[$index] = substr($valueStr, $start, $tokenLength);
  89.         $start = $end;
  90.         $end = $start+$tokenLength;
  91.     }
  92.     return $tokens;
  93. }
  94.  
  95. $pairsCount = substr_count($data, "/");
  96.  
  97. $pairs = parseIt($data, 7, $pairsCount);
  98. $data = substr($data, 7*$pairsCount);
  99.  
  100. $bidBigNumber = parseIt($data, 4, $pairsCount);
  101. $data = substr($data, 4*$pairsCount);
  102.  
  103. $bidPoints = parseIt($data, 3, $pairsCount);
  104. $data = substr($data, 3*$pairsCount);
  105.  
  106. $offerBigNumber = parseIt($data, 4, $pairsCount);
  107. $data = substr($data, 4*$pairsCount);
  108.  
  109. $offerPoints = parseIt($data, 3, $pairsCount);
  110. $data = substr($data, 3*$pairsCount);
  111.  
  112. $highs = parseIt($data, 7, $pairsCount);
  113. $data = substr($data, 7*$pairsCount);
  114. $lows = parseIt($data, 7, $pairsCount);
  115. $data = substr($data, 7*$pairsCount);
  116.  
  117. $msTime = parseIt($data, 13, $pairsCount);
  118. $data = substr($data, 13*$pairsCount);
  119.  
  120.  
  121.  
  122. var_dump($pairs, $bidBigNumber, $bidPoints, $offerBigNumber, $offerPoints, $highs, $lows, $msTime);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top