Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- curl_getinfo output
- [url] => https://crest-tq.eveonline.com/market/10000002/orders/sell/?type=https://crest-tq.eveonline.com/inventory/types/10204/
- [content_type] => application/vnd.ccp.eve.MarketOrderCollection-v1+json; charset=utf-8
- [http_code] => 200
- [header_size] => 614
- [request_size] => 148
- [filetime] => -1
- [ssl_verify_result] => 20
- [redirect_count] => 0
- [total_time] => 2.075
- [namelookup_time] => 0
- [connect_time] => 0.296
- [pretransfer_time] => 1.419
- [size_upload] => 0
- [size_download] => 10580
- [speed_download] => 5098
- [speed_upload] => 0
- [download_content_length] => 10580
- [upload_content_length] => 0
- [starttransfer_time] => 1.778
- [redirect_time] => 0
- [redirect_url] =>
- [primary_ip] => 87.237.34.201
- Actual php
- <?php
- $startTime=time();
- function get_data($url) {
- $ch = curl_init();
- $timeout = 5;
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
- curl_setopt($ch, CURLOPT_POST, false);
- $data = curl_exec($ch);
- $info = curl_getinfo($ch);
- echo '<pre>' . print_r($info);
- curl_close($ch);
- return $data;
- }
- $con = new mysqli('localhost', 'root', '', 'corpmarket');
- if ($con->connect_errno) {
- die('Failed to connect to MySQL: ' . $con->connect_error);
- }
- $region = 10000002;
- $stationid = 60003760;
- $gettradelist_sql = "SELECT typeid FROM corpmarket.tradelist where traded = 1 limit 20";
- $list = $con->query($gettradelist_sql);
- if (false === $list) {
- die('Failed type list query the error was ' . $con->error);
- }
- foreach ($list as $row) {
- if (!array_key_exists('typeid', $row)) {
- print 'No type id found for row <br><pre>';
- print_r($row);
- print '</pre>';
- continue;
- }
- $typeID = $row['typeid'];
- $url = 'https://crest-tq.eveonline.com/market/' . $region . '/orders/sell/?type=https://crest-tq.eveonline.com/inventory/types/' . $typeID . '/';
- $crest = get_data($url);
- $json = json_decode($crest, true);
- $lowest = PHP_INT_MAX;
- foreach ($json['items'] as $item) {
- if ((int)$stationid === (int)$item['location']['id']) {
- $lowest = min($lowest, (float)$item['price']);
- }
- }
- if ($lowest == 2147483647)
- { $lowest = 0; }
- $sql = 'INSERT IGNORE INTO temp_crest_prices (typeID, regionid, stationid, price ) VALUES ';
- $sql .= "('" . implode("','", [$typeID, $region, $stationid, $lowest]) . "')";
- echo $sql . "<br>";
- }
- $endTime = time();
- echo '<br><hr><br>';
- echo 'StartTime: ' . $startTime . '<br>';
- echo 'EndTime: ' . $endTime . '<br>';
- $totalTime = $endTime - $startTime;
- echo 'TotalTime: ' . $totalTime . '<br>';
- ?>
Add Comment
Please, Sign In to add comment