• render.html

    render.html 接口用于获取 JavaScript 渲染的页面的 HTML 代码,接口地址就是 Splash 的运行地址加此接口名称,例如http://localhost:8050/render.html。
    http://0.0.0.0:8050/render.html?url=https://www.baidu.com&wait=5
    http://0.0.0.0:8050 + render.html + url=https://www.baidu.com + wait=5
    import requests
    
    url = 'http://0.0.0.0:8050/render.html?url=https://www.baidu.com&wait=5'
    response = requests.get(url)
    print(response.text) # 运行
    给此接口传递了一个url参数来指定渲染的URL,等待5秒钟,返回结果即页面渲染后的源代码。
  • render.png

    render.png 接口可以获取网页截图,通过 width 和 height 来控制宽高,它返回的是PNG 格式的图片二进制数据。
    http://localhost:8050/render.png?url=https://www.jd.com&wait=5&width=1000&height=700
    http://localhost:8050/render.png?url=https://www.jd.com&wait=5&width=1000&height=700
    import requests
    
    url = 'http://localhost:8050/render.png?url=https://www.jd.com&wait=5&width=1000&height=700'
    response = requests.get(url)
    with open('taobao.png', 'wb') as f:
    f.write(response.content)
  • render.jpng

    render.jpng 接口和 render.png 接口类似,只是多了个 quality 参数来设置图片的质量
    
  • render.har

    render.har 接口用于获取页面加载的HAR数据,它的返回结果非常多,是一个 JSON 格式的数据,其中包含页面加载过程中的 HAR 数据。
    import requests
    
    url = 'http://localhost:8050/render.har?url=https://www.jd.com&wait=5'
    response = requests.get(url)
    with open('jd1.json', 'wb') as f:
    f.write(response.content) # 运行生成一个名为jd.json的文件
  • execute

    最强大的接口
    import requests
    from urllib.parse import quote # lua脚本
    lua = '''
    function main(splash)
    return 'hello'
    end
    ''' # quote()方法将lua脚本进行URL转码。lua_source作为参数传递
    url = 'http://localhost:8050/execute?lua_source=' + quote(lua) response = requests.get(url)
    print(response.text)
    print(quote(lua)) # 输出:
    hello
    %0Afunction%20main%28splash%29%0A%20%20%20%20return%20%27hello%27%0Aend%0A
    import requests
    from urllib.parse import quote lua = '''
    function main(splash, args)
    local treat = require("treat")
    local response = splash:http_get("http://httpbin.org/get")
    return {
    html=treat.as_string(response.body),
    url=response.url,
    status=response.status
    }
    end
    ''' url = 'http://localhost:8050/execute?lua_source=' + quote(lua)
    response = requests.get(url)
    print(response.text)
    print(quote(lua)) # 输出:
    {"html": "{\n \"args\": {}, \n \"headers\": {\n \"Accept-Encoding\": \"gzip, deflate\", \n \"Accept-Language\": \"en,*\", \n \"Host\": \"httpbin.org\", \n \"User-Agent\": \"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/602.1 (KHTML, like Gecko) splash Version/9.0 Safari/602.1\"\n }, \n \"origin\": \"120.239.195.171, 120.239.195.171\", \n \"url\": \"https://httpbin.org/get\"\n}\n", "status": 200, "url": "http://httpbin.org/get"}
    %0Afunction%20main%28splash%2C%20args%29%0A%20%20local%20treat%20%3D%20require%28%22treat%22%29%0A%20%20local%20response%20%3D%20splash%3Ahttp_get%28%22http%3A//httpbin.org/get%22%29%0A%20%20%20%20return%20%7B%0A%20%20%20%20html%3Dtreat.as_string%28response.body%29%2C%0A%20%20%20%20url%3Dresponse.url%2C%0A%20%20%20%20status%3Dresponse.status%0A%20%20%20%20%7D%0Aend%0A
    function main(splash, args)
    local treat = require("treat")
    local response = splash:http_get("http://httpbin.org/get")
    return {
    html=treat.as_string(response.body),
    url=response.url,
    status=response.status
    }
    end // 输出:
    Object
    html: String (length )
    {
    "args": {},
    "headers": {
    "Accept-Encoding": "gzip, deflate",
    "Accept-Language": "en,*",
    "Host": "httpbin.org",
    "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/602.1 (KHTML, like Gecko) splash Version/9.0 Safari/602.1"
    },
    "origin": "120.239.195.171, 120.239.195.171",
    "url": "https://httpbin.org/get"
    }
    status:
    url: "http://httpbin.org/get"

    Lua脚本

Splash API 调用的更多相关文章

  1. Vue.js——使用$.ajax和vue-resource实现OAuth的注册、登录、注销和API调用

    概述 上一篇我们介绍了如何使用vue resource处理HTTP请求,结合服务端的REST API,就能够很容易地构建一个增删查改应用.这个应用始终遗留了一个问题,Web App在访问REST AP ...

  2. 信鸽推送 .NET (C#) 服务端 SDK rest api 调用库(v1.2)

    信鸽推送 .NET  服务端 SDK rest api 调用库-介绍 该版本是基于信鸽推送v2版本的时候封装的,先拿出来与大家分享,封装还还凑合,不依赖其他http调用件,唯一依赖json序列化dll ...

  3. xmlrpc实现bugzilla api调用(无会话保持功能,单一接口请求)

    xmlrpc实现bugzilla4   xmlrpc api调用(无会话保持功能,单一接口请求),如需会话保持,请参考我的另外一篇随笔(bugzilla4的xmlrpc接口api调用实现分享: xml ...

  4. FormatMessage与GetLastError配合使用,排查windows api调用过程中的错误

    前一段时间在学习windows api调用过程中,遇到过一些调用错误或者程序没能显示预期的结果,或者直接出现vc运行时错误. 这对新手来说是司空见惯的事,因为不太熟悉难免会出错,出错的信息如果能显示很 ...

  5. Sphinx中文分词安装配置及API调用

    这几天项目中需要重新做一个关于商品的全文搜索功能,于是想到了用Sphinx,因为需要中文分词,所以选择了Sphinx for chinese,当然你也可以选择coreseek,建议这两个中选择一个,暂 ...

  6. (36)老版和新版API调用

    ---------更新时间18:06 2016-09-18 星期日------- *前言   我用的是odoo8,但里面有相当多的api是以前版本,这时若我们自己开发的   插件采用新版本api,里面 ...

  7. Sphinx中文分词详细安装配置及API调用实战

    这几天项目中需要重新做一个关于商品的全文搜索功能,于是想到了用Sphinx,因为需要中文分词,所以选择了Sphinx for chinese,当然你也可以选择coreseek,建议这两个中选择一个,暂 ...

  8. 控制ASP.NET Web API 调用频率与限流

    ASP.NET MVC 实现 https://github.com/stefanprodan/MvcThrottle ASP.NET WEBAPI 实现 https://github.com/stef ...

  9. jquery api调用

    本框架内置组件以及部分插件都可以通过jquery选择器进行API调用,支持链式操作,如下示例. <script type="text/javascript"> $(&q ...

随机推荐

  1. Python简单的登录注册代码

    #-*- coding: utf-8 -*- import hashlib # 定义数据库(声明字典) #注册登录的简单hash处理 db={} def get_md5(password): md5= ...

  2. Pots POJ 3414

    /* *POJ 3414 *简单模板bfs *编程应该为了方便理解,尽量提供接口 */ #include<cstdio> #include<algorithm> #includ ...

  3. Forest plot(森林图) | Cox生存分析可视化

    本文首发于“生信补给站”微信公众号,https://mp.weixin.qq.com/s/2W1W-8JKTM4S4nml3VF51w 更多关于R语言,ggplot2绘图,生信分析的内容,敬请关注小号 ...

  4. php导出excel乱码怎么处理

    使用PHP导出excel文档,有时候莫名其妙就会出现导出的数据乱码,现在推荐一个万能修补大法 话不多说,直接上代码 核心就是在处理完数据之后,输出excel文件之前 添加 ob_end_clean() ...

  5. 小程序webview跳转页面后没有返回按钮完美解决方案

    随着小程序越来越火爆,使一个产品如果只有公众号H5页面和APP显得不怎么完美,总感觉不搭上小程序这趟流量车,就会少了点什么,心里别扭地很.在此驱动下,我所在公司也决定赶紧上车. 但是,如果要按照小程序 ...

  6. Linux 命令个人笔记

    [表示命令]man -f [] 显示一个命令的功能whatis [] 显示一个命令的功能ls -lR | grep '^-' | wc -l 统计一个目录下总共有多少个文件head [-n numbe ...

  7. Windows内核编程时的习惯与注意事项

    Windows内核分析索引目录:https://www.cnblogs.com/onetrainee/p/11675224.html 一.内核编程注意细节: 在头文件中使用的是 <ntddk.h ...

  8. 面试常考各类排序算法总结.(c#)

    前言 面试以及考试过程中必会出现一道排序算法面试题,为了加深对排序算法的理解,在此我对各种排序算法做个总结归纳. 1.冒泡排序算法(BubbleSort) 1.1 算法描述 (1)比较相邻的元素.如果 ...

  9. 【JZOJ4807】破解

    Description 历经千辛万苦,ddddddpppppp 终于找到了IBN5100. dp 事先了解到SERN 共有T 个密码,每个密码是一个长度为N 的01 串,他要利用IBN5100 的特殊 ...

  10. 关于Python读写Excel

    关于Excel的读写本人最近看到一篇不错的文章话不多少直接连接https://blog.csdn.net/qq_41185868/article/details/80469355