html-redirect:生成 HTML 重定向页面

  • a7_798388
    了解作者
  • 8.1KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-05-22 05:24
    上传日期
html 重定向 生成 HTML 重定向页面。 例子 htmlRedirect ( 'http://example.com' ) . pipe ( fs . createWriteStream ( 'example1.html' ) ) ; 示例1.html: <!DOCTYPE html > < html > < head > < title > (redirect) </ title > < meta http-equiv =" refresh " content =" 1;url=http://example.com/ " > < script > window . location . replace ( "http://example.com/" ) ; </ script > </ head > < body > < a hre
html-redirect-master.zip
  • html-redirect-master
  • src
  • template.html
    184B
  • index.js
    3.2KB
  • test
  • core.js
    1.6KB
  • options.js
    2.4KB
  • stream.js
    1.5KB
  • usage.txt
    280B
  • .travis.yml
    38B
  • LICENSE
    1.1KB
  • README.md
    3.9KB
  • .gitignore
    14B
  • cli.js
    591B
  • package.json
    1.1KB
内容介绍
[![npm](https://nodei.co/npm/html-redirect.png)](https://nodei.co/npm/html-redirect/) # html-redirect [![Build Status][travis-badge]][travis] [![Dependency Status][david-badge]][david] [travis]: https://travis-ci.org/eush77/html-redirect [travis-badge]: https://travis-ci.org/eush77/html-redirect.svg [david]: https://david-dm.org/eush77/html-redirect [david-badge]: https://david-dm.org/eush77/html-redirect.png Generate HTML redirection page. ## Example ```js htmlRedirect('http://example.com') .pipe(fs.createWriteStream('example1.html')); ``` example1.html: ```html <!DOCTYPE html> <html> <head> <title>(redirect)</title> <meta http-equiv="refresh" content="1;url=http://example.com/"> <script>window.location.replace("http://example.com/");</script> </head> <body><a href="http://example.com/" rel='nofollow' onclick='return false;'>Click me</a></body> </html> ``` ## API ### htmlRedirect(url, [options]) Returns a readable stream of HTML. | Option | Type | Required? | Default | | :---------- | :------ | :-------: | :------ | | timeout | number | No | `1` | | title | string | No | | | placeholder | string | No | | | replaceBody | boolean | No | `false` | `options.timeout` is a timeout for meta-tag redirection. JS redirection will fire instantaneously regardless of the value of this option. `options.title` is the value of `<title>`. `options.placeholder` is either the text under default `<a rel='nofollow' onclick='return false;'>` or the whole `<body>` in HTML depending on `options.replaceBody`. ### htmlRedirect.createStream(url, [options]) Returns a transform stream. Body content &rarr; HTML page. | Option | Type | Required? | Default | | :---------- | :------ | :-------: | :------ | | timeout | number | No | `1` | | title | string | No | | ## CLI ``` Usage: html-redirect [OPTION]... URL Options: --title Page title --placeholder Text under <a rel='nofollow' onclick='return false;'> in the page body, or the page body itself --replace-body If true, --placeholder replaces the whole body of a page --timeout http-equiv refresh timeout ``` ## More examples ### Set some options ```js htmlRedirect('http://example.com', { timeout: 0, title: 'please wait...', placeholder: 'Your browser does not support redirection. Please click this link.' }).pipe(fs.createWriteStream('example2.html')); ``` example2.html: ```html <!DOCTYPE html> <html> <head> <title>please wait...</title> <meta http-equiv="refresh" content="0;url=http://example.com/"> <script>window.location.replace("http://example.com/");</script> </head> <body><a href="http://example.com/" rel='nofollow' onclick='return false;'>Your browser does not support redirection. Please click this link.</a></body> </html> ``` ### Replace body ```js htmlRedirect('http://example.com', { timeout: 3, title: 'please wait...', placeholder: 'Your browser does not support redirection. Please click <a href="http://example.com" rel='nofollow' onclick='return false;'>this link</a>.', replaceBody: true }).pipe(fs.createWriteStream('example3.html')); ``` example3.html: ```html <!DOCTYPE html> <html> <head> <title>please wait...</title> <meta http-equiv="refresh" content="3;url=http://example.com/"> <script>window.location.replace("http://example.com/");</script> </head> <body>Your browser does not support redirection. Please click <a href="http://example.com" rel='nofollow' onclick='return false;'>this link</a>.</body> </html> ``` ### Use it as a transform stream example4.js: ```js process.stdin .pipe(htmlRedirect.createStream('http://example.com/')) .pipe(process.stdout); ``` Try it in the console: ``` printf 'Contents from the <b>stdin</b>.' |node example.js ``` ``` <!DOCTYPE html> <html> <head> <title>(redirect)</title> <meta http-equiv="refresh" content="1;url=http://example.com/"> <script>window.location.replace("http://example.com/");</script> </head> <body>Contents from the <b>stdin</b>.</body> </html> ``` ## Install ```shell npm install html-redirect ``` ## License MIT
评论
    相关推荐
    • swim.html:http
      swim.html 来源
    • Html2Xaml:http的分叉
      Html2Xaml 这不是将 html 转换为 xaml 的好方法,我认为最好将其转换为列表,并通过 ListView 显示内容
    • Lingulo-Responsive-Tutorial:httpHTML5自适应网站教程
      语言响应式教程 HTML5自适应网站教程, 此HTML5网站是Christoph Anastasiades创建HTML5 / CSS3教程的一部分( )随意使用用于您的个人或商业项目...为了最大程度地减少HTTP请求的数量,请将所有CSS文件合并为一个文件
    • Cryptoquips:这个简单的应用程序从http解析html
      密码学 这个简单的应用程序解析html,并在卡视图中显示列出的Cryptoquip图像。
    • Lightweight C-HTTP & HTML Wrapper:轻量级的C-HTTPHTML包装器-开源
      它是一个C-HTTPHTML包装器,用于自动处理Web数据。 一些示例是:-接收网站以检查其是否正常运行-从例如下载您的个人数据。 网上银行,帐单...-处理网站中包含的数据,例如天气数据-接收大量数据,尤其是对网站...
    • slackify-html
      slackify-htmlhtml转换为 用法示例: var slackify = require('slackify-html'); var text = slackify('this <a>link</a> is <b>important</b>');...// text variable contains 'this <http> is *important*'
    • HTML5-Examples:httpHTML 5示例-html source website
      HTML5-示例 HTML 5示例。 版权所有2012:SKJ Technologies Private Ltd 这些示例已根据“知识共享署名-相同的ShareAlike 3.0未移植”(CC BY-SA 3.0)许可证进行共享。 有关CC BY-SA 3.0许可证的更多详细信息,请...
    • html定时抓取程序
      利用http协议,定时抓取指定网页内容,保存为.htm文件的程序;利用http协议,定时抓取指定网页内容,保存为.htm文件的程序;
    • html日期控件
      http://hiyu2218.bokele.com/?CH=6441
    • SIM800C_MQTT.rar
      使用SIM800C模块,使用MQTT协议,连接中国移动onenet平台,能实现数据的订阅、发布、存储等