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首页。

  • 相关阅读:
    前端框架AngularJS入门
    springcloud---Eureka yml
    springcloud 的Eureka配置
    虚拟机中文件和目录的相关操作
    SpringBoot整合Redis
    IDEA整合GIT操作
    Ubuntu 安装步骤
    Centos 7 安装
    Centos 6 安装步骤
    防止root口令被破解
  • 原文地址:https://www.cnblogs.com/ydf0509/p/7340533.html
Copyright © 2011-2022 走看看