一 set_content()

1 点睛

用来设置页面内容。

2 代码

function main(splash)
    assert(splash:set_content("<html><body><h1>hello</h1></body></html>"))
    return splash:png()
end

3 效果

爬虫之Splash对象方法(三)

二 html()

1 点睛

获取网页的源代码。

2 代码

function main(splash, args)
  splash:go("https://httpbin.org/get")
  return splash:html()
end

3 效果

爬虫之Splash对象方法(三)

三 png()

1 点睛

获取PNG格式的网页截图。

2 代码

function main(splash, args)
  splash:go("https://www.taobao.com")
  return splash:png()
end

3 效果

爬虫之Splash对象方法(三)

四 jpeg()

1 点睛

获取JPEG格式的网页截图

2 代码

function main(splash, args)
  splash:go("https://www.taobao.com")
  return splash:jpeg()
end

3 效果

爬虫之Splash对象方法(三)

五 har()

1 点睛

获取页面加载过程描述。

2 代码

function main(splash, args)
  splash:go("https://www.baidu.com")
  return splash:har()
end

3 效果

爬虫之Splash对象方法(三)

六 url()

1 点睛

获取当前正在访问的URL。

2 代码

function main(splash, args)
  splash:go("https://www.baidu.com")
  return splash:url()
end

3 运行结果

Splash Response: "https://www.baidu.com/"

 

相关文章:

  • 2022-03-03
  • 2021-08-04
  • 2021-07-13
  • 2021-11-30
  • 2022-02-11
  • 2021-12-05
  • 2022-12-23
  • 2021-07-22
猜你喜欢
  • 2021-06-23
  • 2021-11-05
  • 2021-11-23
  • 2022-12-23
  • 2021-07-15
  • 2021-11-08
  • 2021-08-02
相关资源
相似解决方案