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

 

 

posted @ 2017-08-10 17:43  北风之神0509  阅读(441)  评论(0编辑  收藏  举报