zoukankan      html  css  js  c++  java
  • splash渲染网页

    #coding=utf8
    import requests,time,random
    import threadpool
    
    render_html = 'http://192.168.30.128:8050/render.html'  ##填写你的地址
    url=’http://s.weibo.com/weibo/%25E8%25B5%25B5%25E9%259B%2585%25E8%258A%259D?topnav=1&wvr=6&b=1'
    headerx = {'User-Agent':'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0'}
    datax = {"url": url, "wait": 30, 'images': 0, 'timeout': 90 }  #如果要使用代理ip加上这个 ,'proxy':pr}  # ,'proxy': 'http://119.115.233.93:8118'}
    
    responsex=requests.get(url=render_html ,headers=headerx,params=datax)
    return responsex
     

    splash 文档地址 http://splash.readthedocs.io/en/latest/scripting-tutorial.html

    docker安装,自己百度。

    装完docker后,运行

    docker pull scrapinghub/spalsh

    docker run -d -p 8050:8050 scrapinghub/spalsh

    之后使用这个函数请求就可以得到渲染后的地址了。

    电脑打开,http://192.168.30.128:8050/render.html  (换成你自己的ip),可以在这里面测试,例如打开chinaz首页。

  • 相关阅读:
    drf框架 APView的请求生命周期
    web API接口、restful规范
    vue项目安装插件配置
    vue项目、路由
    day67
    vue组件
    day66
    HDFS(Hadoop Distribute File System)
    JVM运行优化学习笔记
    ELK(检索)
  • 原文地址:https://www.cnblogs.com/ydf0509/p/7340533.html
Copyright © 2011-2022 走看看