如何快速镜像一个网站
仅需下述几个步骤即可快速镜像一个网站,镜像的内容包括html,js,css,image等静态页面资源,暂时无法镜像有用户交互的动态页面。
1、安装wget工具,以ubuntu系统为例
sudo apt-get install wget
2、下载网站资源
以网站http://www.szsh-gov.com/为例,静态页面比较多
执行如下命令:
wget -r -p -np -k http://www.szsh-gov.com/
下载完成后,查看本地目录结构如下:
3、搭建本地轻量级web服务
下载python + bottle作为轻量级的web框架,以ubuntu为例
sudo apt-get install python
sudo pip install bottle
在上图同级目录创建main.py文件,内容如下
#coding=utf-8
from bottle import route,request,template,view,run,Bottle,static_file,get, post, response
import bottle@get("/js/<filepath:re:.*\.(css|jpg|png|gif|ico|svg|js|eot|otf|svg|ttf|woff|woff2?)>")
def szsh1(filepath):return static_file(filepath, root="js")
@get("/js2/<filepath:re:.*\.(css|jpg|png|gif|ico|svg|js|eot|otf|svg|ttf|woff|woff2?)>")
def szsh2(filepath):return static_file(filepath, root="js2")
@get("/images/<filepath:re:.*\.(css|jpg|png|gif|ico|svg|js|eot|otf|svg|ttf|woff|woff2?)>")
def szsh3(filepath):return static_file(filepath, root="images")
@get("/images2/<filepath:re:.*\.(css|jpg|png|gif|ico|svg|js|eot|otf|svg|ttf|woff|woff2?)>")
def szsh4(filepath):return static_file(filepath, root="images2")
@get("/css/<filepath:re:.*\.(css|jpg|png|gif|ico|svg|js|eot|otf|svg|ttf|woff|woff2?)>")
def szsh5(filepath):return static_file(filepath, root="css")
@get("/css2/<filepath:re:.*\.(css|jpg|png|gif|ico|svg|js|eot|otf|svg|ttf|woff|woff2?)>")
def szsh6(filepath):return static_file(filepath, root="css2")
@get("/uploadfile/<filepath:re:.*\.(css|jpg|png|gif|ico|svg|js|eot|otf|svg|ttf|woff|woff2?)>")
def szsh7(filepath):return static_file(filepath, root="uploadfile")
@get("/html/<filepath:re:.*\.(html|1)>")
def szsh8(filepath):return static_file(filepath, root="html")
@get("/2016/<filepath:re:.*\.(html)>")
def szsh9(filepath):return static_file(filepath, root="2016")
@get("/2017/<filepath:re:.*\.(html)>")
def szsh10(filepath):return static_file(filepath, root="2017")
@get("/2020/<filepath:re:.*\.(html)>")
def szsh11(filepath):return static_file(filepath, root="2020")
@get("/2021/<filepath:re:.*\.(html)>")
def szsh12(filepath):return static_file(filepath, root="2021")
@get("/active/<filepath:re:.*\.(html)>")
def szsh13(filepath):return static_file(filepath, root="active")
@get("/complaint/<filepath:re:.*\.(html)>")
def szsh14(filepath):return static_file(filepath, root="complaint")
@get("/event/<filepath:re:.*\.(html)>")
def szsh15(filepath):return static_file(filepath, root="event")
@get("/policy/<filepath:re:.*\.(html)>")
def szsh16(filepath):return static_file(filepath, root="policy")
@get("/research/<filepath:re:.*\.(html)>")
def szsh17(filepath):return static_file(filepath, root="research")
@get("/service/<filepath:re:.*\.(html)>")
def szsh18(filepath):return static_file(filepath, root="service")
@get("/<filepath:re:.*\.(html)>")
def szsh19(filepath):return static_file(filepath, root="") @route('/',method = 'GET')
def index():return template("index" , result = [])run(host='0.0.0.0',port=8888)
执行如下命令,启动web服务
python main.py
[WARNING] wkhtmltopdf is not installed/configured properly. PDF Report Generation is disabled
Bottle v0.13-dev server starting up (using WSGIRefServer())...
Listening on http://0.0.0.0:8888/
Hit Ctrl-C to quit.
本地访问,效果如下:
4、总结
总体思路是,先用wget下载整个网站静态资源到本地,然后通过一个轻量级的web框架,搭建web服务。
我选择python + bottle作为web框架(超简单),小伙伴们根据个人喜好,也可以选择其他web框架。
如何快速镜像一个网站相关推荐
- windows和Linux利用Python快速搭建一个网站
windows和Linux利用Python快速搭建一个网站 一.windows 步骤1:安装Python3(自行百度) 步骤2:在cmd窗口输入ipconfig查看本机ip地址,IPV4那一行.如:1 ...
- 快速获取一个网站的所有资源,图片,html,css,js......扒站,仿站必备工具
今天介绍一款软件,可以快速获取一个网站的所有资源,图片,html,css,js...... 以获取某车官网为例 我来展示一下这个软件的功能. 输入网站地址和网站要保存的文件夹 如果网站名称后我们可以扫 ...
- linux使用wget镜像一个网站
镜像一个网站的命令: wget -c -m -np -p -k -E -P YourDirectory http://www.server-world.info/en/ -c 断点叙传 -np 不下载 ...
- 不懂建站技术如何快速搭建一个网站
不懂建站技术如何快速搭建一个网站 虽说时代已经发展到手机上网时代了,而且是各种短视频和直播的网络时代,但对于一部分热爱网络的新潮来说"网站"依然是他们的兴趣所在. 而对于这些人来说 ...
- easyswoole数据库连接池_easyswoole快速实现一个网站的api接口程序
目前,easyswoole已经成为了最知名的swoole框架之一,本人也用easyswoole开发过很多个项目了,现在就来讲一讲如何用easyswoole快速实现一个网站的curd功能的接口. 安装e ...
- 手把手教(超详细):个人如何快速建立一个网站
很多不是程序员的朋友总是理解不了网站到底是什么,它到底是怎么存在和运行的,也总是以为建一个网站很复杂.其实建网站并不难,也不需要花费太大资金,只需要以下6个步骤即可做出一个网站. 第一步:注册域名并实 ...
- 1小时快速搭建一个网站
之前一直想搭建一个个人网站,但是因为需要买域名还需买空间以及部署等,对一个小白来说既费钱也费精力.下面介绍一个免费的方式快速建立一个个人网站. 注意:将username替换为你的github用户名. ...
- 如何使用ChatGPT快速构建一个网站模板
前端Q 我是winty,专注分享前端知识和各类前端资源,乐于分享各种有趣的事,关注我,一起做个有趣的人- 公众号 点击上方 前端Q,关注公众号 回复加群,加入前端Q技术交流群 英文 | https:/ ...
- 如何使用ChatGPT快速构建一个网站模板?
欢迎来到令人兴奋的自然语言处理和机器学习世界!今天,我们将探索 ChatGPT 的功能,它是由 OpenAI 公司开发的目前最先进的人工智能工具.当然,你也可以将其看作是一个智能机器人.ChatGPT ...
最新文章
- ORACLE SQL开发where子句之case-when
- 解决pycharm输入法不跟随的方法
- 图解Windows下开发Objective-C程序之二 - Objective-C入门例子
- 市电会引起UPS产生故障吗
- IntelliJ IDEA添加过滤文件或目录(转)
- vcard 2.1介绍
- 2pin接口耳机_悦耳好音质,续航10小时,用了小米生态链这款耳机,扔掉其它吧...
- 使用mac以来的一些认识
- axios异步请求数据的简单使用
- 花书+吴恩达深度学习(四)多分类 softmax
- GAN——流形(manifold)
- ubuntu网络正常连接但无法上网
- 女暴徒BeHype:MINT和Raffle抽奖规则及答疑
- 数据结构:八大数据结构分类
- js 日历,节假日,添加日志
- CVPR 2020 最佳论文提名 | 神经网络能否识别镜像翻转
- 四、回归分析之线性回归模型构建
- leaflet快速渲染聚合矢量瓦片(附源码下载)
- 兆骑科创创新创业大赛活动举办,线上直播路演,投融资对接
- js使用input上传文件夹、拖拽上传文件夹并将文件夹结构展示为树形结构