TestController.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. namespace App\Http\Controllers\Api\v1;
  3. use App\Http\Controllers\Api\webApp;
  4. use App\Services\RedisService;
  5. use Illuminate\Support\Facades\DB;
  6. use QL\QueryList;
  7. /**
  8. * 测试
  9. * Class TestController
  10. * @package App\Http\Controllers\Api
  11. */
  12. class TestController extends webApp
  13. {
  14. public function index()
  15. {
  16. $key = md5('clearTrade');
  17. return message(1002, true, $key);
  18. }
  19. public function betList1()
  20. {
  21. //第一步:获取cookie
  22. $cookieFile = ROOT_PATH . '/public/cookie.tmp';
  23. $url = 'http://86524391-jf.for9dong.com/login';
  24. $data = array(
  25. 'type' => 2,
  26. 'account' => 'xxcc666',
  27. 'password' => 'AAbb1122',
  28. 'code' => '6497',
  29. 'facode' => '',
  30. );
  31. //curl初始化
  32. $ch = curl_init();
  33. curl_setopt($ch, CURLOPT_URL, $url);
  34. //设置为post请求
  35. curl_setopt($ch, CURLOPT_POST, true);
  36. //设置附带返回header信息为空
  37. curl_setopt($ch, CURLOPT_HEADER, 0);
  38. //post数据
  39. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  40. //cookie保存文件位置
  41. curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile);
  42. //设置数据返回作为变量储存,而不是直接输出
  43. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  44. //执行请求
  45. $ret = curl_exec($ch);
  46. var_dump($ret);
  47. //关闭连接
  48. curl_close($ch);
  49. //第二步:附带cookie请求需要登陆的页面
  50. $url = 'https://86524391-jf.for9dong.com/agent/report/list?detail=true&begin=2023-02-28&end=2023-02-28&settle=true&lottery=PK10JSC';
  51. //curl初始化
  52. $ch = curl_init();
  53. curl_setopt($ch, CURLOPT_URL, $url);
  54. //设置为post请求
  55. curl_setopt($ch, CURLOPT_POST, true);
  56. //设置附带返回header信息为空
  57. curl_setopt($ch, CURLOPT_HEADER, 0);
  58. //设置cookie信息文件位置, 注意与第二步中的获取不同,这里是读取
  59. curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);
  60. //设置数据返回作为变量储存,而不是直接输出
  61. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  62. //执行请求
  63. $ret = curl_exec($ch);
  64. var_dump($ret);
  65. //关闭连接
  66. curl_close($ch);
  67. }
  68. public function betList()
  69. {
  70. /**
  71. *
  72. * 东郲
  73. * 213808.app
  74. * 661182FF
  75. * xxcc666
  76. * AAbb1122
  77. */
  78. set_time_limit(0);
  79. $cookie = 'ssid1=ac7aeb26742b7642d45a0605d4749266; random=549; token=f06742d5c5d6f66606d86bc28f279f12a3d831fa';
  80. $url = 'https://86524391-jf.for9dong.com/agent/report/bets?username=bnm368&lottery=PK10JSC&begin=2023-02-28&end=2023-02-28&settle=true';
  81. $header = ["Cookie: ssid1=a6d82ef49895683ce8789c1ef0141163; random=9338; token=e11c72348bc5f0b654957495154f6dbaff1307d7","User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","Host: 86524391-jf.for9dong.com","Connection: keep-alive","Referer: https://86524391-jf.for9dong.com/agent/report/list?username=yyy1999&lottery=PK10JSC&detail=true&begin=2023-02-28&end=2023-02-28&settle=true"];
  82. $page = request('page');
  83. // $html = grabRequest($url.'&page='.$page, $header, '', 'get', 'text', '',10);
  84. //var_dump($html);
  85. // return 0;
  86. $pageNum = 2730;
  87. $endPage = 50;
  88. $datas = [];
  89. $page = request('page');
  90. $endPage = request('endPage');
  91. for($i = $page; $i<=$endPage;){
  92. $html = grabRequest($url.'&page='.$i, $header, '', 'get', 'text', '',10);
  93. $queryList = QueryList::html($html)->rules([
  94. 'order_sn'=> ['td>a:eq(0)','text'],
  95. 'time'=> ['td:eq(1)','text'],
  96. 'gameName'=> ['td.period','html','-div'],
  97. 'period'=> ['td.period>div','text'],
  98. 'account'=> ['td:eq(3)','html','-div'],
  99. 'region'=> ['td:eq(3)>div','text'],
  100. 'code'=> ['td>span:eq(0)','text'],
  101. 'odds'=> ['.odds','text'],
  102. 'money'=> ['.money','text'],
  103. 'commission'=> ['.commission','text'],
  104. 'result'=> ['.dividend','text'],
  105. 'share'=> ['.share','text'],
  106. 'result1'=> ['td:eq(9)','text'],
  107. ])->range('tr')->query()->getData();
  108. $queryList = $queryList->all();
  109. if($queryList){
  110. foreach ($queryList as $item ){
  111. if($item['order_sn'] && !DB::table('test_logs')->where(['order_sn'=> $item['order_sn'],'page'=> $i])->value('id')){
  112. $item['page'] = $i;
  113. $item['money'] = floatval($item['money']);
  114. $item['code'] = str_replace(['『','』'],['[',']'], $item['code']);
  115. $datas[] = $item;
  116. //RedisService::set('order:'.$item['order_sn'], 11, 60000);
  117. }
  118. }
  119. }
  120. $i++;
  121. }
  122. DB::table('test_logs')->insert($datas);
  123. return message(1002, true, $datas);
  124. }
  125. }