抽取网页图片
最后更新于:2022-04-02 08:18:03
## 抽取网页图片
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/64/a9/64a935ac714f8a8c6abd26531aa29552_200x200.png)
> 该接口可以抽取网页中任何图片,并支持指定的图片格式。默认抽取全部格式的图片,如只抽取网页中的png图片,则传递参数format=>'png'即可。由于网页标签结构错综复杂,所以无法保证全部网页有效。
>[danger] 请注意:有些url地址是http开头的,但实际访问时会跳转到https,请用跳转后的真实地址传参。
## 接口费用( [点击购买](https://market.topthink.com/product/353))
> 最低 0.01元/次
## 接口调用([调用须知](https://docs.topthink.com/think-api/1835086))
### 请求地址
```
GET https://api.topthink.com/website/htmlpic
```
### 请求参数
| 名称 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| appCode| string| 是|用户授权码,参考[API调用](https://docs.topthink.com/think-api/1835086) |
| url | string | 是 | URL地址,支持http/https |
| format | string | 否 |图片格式,如png |
### 返回`data`参数
| 名称 | 类型 | 说明 |
| --- | --- | --- |
| picUrl | string | 图片地址 |
## SDK调用
```
$client = new Client("YourAppCode");
$result = $client->websiteHtmlpic()
->withUrl('https://www.163.com/dy/article/FUHJ79KM0519WCJG.html')
->request();
dump($result);
```
JSON返回示例:
~~~
{
code: 0,
message: "成功",
data: [
{
"picUrl": "https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F1223%2Ffb46cb01j00qlrzzz0024c000m700e5m.jpg&thumbnail=650x2147483647&quality=80&type=jpg"
},
{
"picUrl": "https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F1223%2Fe069c454p00qlrzzz0023c000pt00i1m.png&thumbnail=650x2147483647&quality=80&type=jpg"
},
{
"picUrl": "https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F1223%2Fca2ea539p00qlrzzz006xc000ep00gqm.png&thumbnail=650x2147483647&quality=80&type=jpg"
},
{
"picUrl": "https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F1223%2Ff93405f3p00qlrzzz008xc000hs00c2m.png&thumbnail=650x2147483647&quality=80&type=jpg"
},
{
"picUrl": "https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F1223%2F2eade462p00qlrzzz00c8c000hs00c2m.png&thumbnail=650x2147483647&quality=80&type=jpg"
},
{
"picUrl": "https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F1223%2F4d20f25bp00qlrzzz00grc000ic00cim.png&thumbnail=650x2147483647&quality=80&type=jpg"
},
{
"picUrl": "https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F1223%2F48a6b282p00qlrzzz00tyc000u000jzm.png&thumbnail=650x2147483647&quality=80&type=jpg"
},
{
"picUrl": "https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F1223%2Fa9ee18bdp00qlrzzz00axc000hs00d1m.png&thumbnail=650x2147483647&quality=80&type=jpg"
},
{
"picUrl": "https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F1223%2F446f6a41p00qlrzzz006gc000i5009em.png&thumbnail=650x2147483647&quality=80&type=jpg"
},
{
"picUrl": "https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F1223%2Fe356674ap00qlrzzz00b7c000hs00bum.png&thumbnail=650x2147483647&quality=80&type=jpg"
}
]
}
~~~
';