介绍
有一些gtp网页是可以抓到它的数据接口的,打开网页,按F12
进行抓包,获取他的接口,实现白嫖的方法,也可以利用这个接口自己搭建个API接口,白嫖
抓包
站点:https://ai.haircv.com/
很显然这是他的数据包,post
请求,也可以看到他响应的内容
{/card-list-item}
代码
下面是获取接口,然后再调用成一个API,自己新建一个php文件,就可调用了
<?php
$msg = $_GET['msg'];//需要提问的内容
// 构建 POST 请求的数据
$data = array(
'messages' => array(
array(
'role' => 'system',
'content' => 'IMPORTANT: You are a virtual assistant powered by the gpt-3.5-turbo model, now time is '
),
array(
'role' => 'user',
'content' => $msg
)
),
'stream' => true,
'model' => 'gpt-3.5-turbo',
'temperature' => 0.5,
'presence_penalty' => 0
);
// 发送 POST 请求
$curl = curl_init();
$url = 'https://ai.haircv.com/api/openai/v1/chat/completions'; //这里填你抓到的接口
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$response = curl_exec($curl);
curl_close($curl);
//数据处理
$pattern = '/content\":\"(.*?)\"}/';
preg_match_all($pattern, $response, $matches);
foreach ($matches[1] as $result) {
echo $result;
}
Warning: file_get_contents(http://ip.taobao.com/outGetIpInfo?ip=61.163.12.31&accessKey=alibaba-inc): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /www/wwwroot/blog.521r.cn/usr/themes/Joe-master/core/function.php on line 73
unknown ·Windows 10 · Google Chrome
学习到了,感谢博主
终于找到这篇文章了,感谢作者的分享!