合作抓取带鉴权接口文档
抓取带鉴权接口文档
- 接口简介
本接口是针对需要鉴权的数据抓取而设计的,使用前需要先进行身份认证,认证后才能使用本接口进行数据抓取。
- 接口参数
参数名称 | 参数类型 | 是否必须 | 参数描述 ---|---|---|--- access_token | string | 是 | 认证凭证,用于鉴权 url | string | 是 | 需要抓取的网页地址 method | string | 否 | 请求方式,默认为GET headers | object | 否 | 自定义请求头,用于模拟浏览器请求 params | object | 否 | 请求参数,用于模拟表单提交 timeout | int | 否 | 超时时间,单位为秒,默认为10秒
- 接口返回值
返回值是抓取到的网页内容,以UTF-8编码的字符串形式返回。如果抓取失败,返回空字符串。
- 接口示例
请求地址:
https://api.example.com/crawler
请求参数:
{
"access_token": "xxxxxxxxxxx",
"url": "https://www.example.com/",
"method": "GET",
"headers": {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
},
"params": {
"q": "python"
},
"timeout": 30
}
返回值:
<!DOCTYPE html>
<html>
<head>
<title>Example Domain</title>
<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type="text/css">
body {
background-color: #f0f0f2;
margin: 0;
padding: 0;
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
div {
width: 600px;
margin: 5em auto;
padding: 5em 20px;
background-color: #fff;
border-radius: 1em;
box-shadow: 0 3px 5px rgba(0,0,0,0.5);
}
a:link, a:visited {
color: #38488f;
text-decoration: none;
}
@media (max-width: 700px) {
body {
background-color: #fff;
}
div {
width: auto;
margin: 0 auto;
border-radius: 0;
box-shadow: none;
padding: 1em;
}
}
</style>
</head>
<body>
<div>
<h1>Example Domain</h1>
<p>This domain is established to be used for illustrative examples in documents. You may use this domain in examples without prior coordination or asking for permission.</p>
<p><a href="https://www.iana.org/domains/example">More information...</a></p>
</div>
</body>
</html>
``
原文地址: https://www.cveoy.top/t/topic/ePXy 著作权归作者所有。请勿转载和采集!