This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding: utf-8 | |
# 文件名 tuoshui.rb | |
# 将天涯易读的帖子中的内容抓出来并打印 | |
# 使用方法: | |
# ruby tuoshui.rb [天涯易读帖子id] > result.txt | |
# 如果没有在运行脚本时指定帖子id的话,默认id为40489 | |
require 'watir-webdriver' | |
def build_url(id) | |
sprintf('http://www.tianyayidu.cc/article-a-%d-%%d.html', id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'base64' | |
binary = File.open(File.join('.', 'img.jpg'), 'rb') do |io| | |
io.read | |
end | |
encoded = Base64.encode64(binary) | |
printf('<img src="data:image/jpeg;base64,%s"></img>', encoded) | |
# ruby encode_img.rb > img.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |
<title>basic css selector</title> | |
<style> | |
p {color: blue} | |
</style> | |
</head> | |
<body> | |
<p>昔人已乘黄鹤去,此地空余黄鹤楼,黄鹤一去不复返,白云千载空悠悠。</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |
<title>显示和隐藏</title> | |
<script type="text/javascript"> | |
function show(){ | |
document.getElementById('show').style.display = "block" | |
} | |
</script> | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |
<title>inline style</title> | |
</head> | |
<body> | |
<p style="color:red" >昔人已乘黄鹤去,此地空余黄鹤楼,黄鹤一去不复返,白云千载空悠悠。</p> | |
<p style ="color:blue">晴川历历汉阳树,芳草萋萋鹦鹉洲。日暮乡关何处是,烟波江上使人愁。</p> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |
<title>iframe</title> | |
</head> | |
<body> | |
<h3>内嵌框架</h3> | |
<iframe src="http://www.baidu.com/" width="800" height="600"></iframe> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |
<title>有表头的表格</title> | |
</head> | |
<body> | |
<h3>有的表格-3行3列</h3> | |
<table border > | |
<thead> | |
<th>姓名</th> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |
<title>最简单的表格</title> | |
</head> | |
<body> | |
<h3>简单的表格-3行3列</h3> | |
<table> | |
<tr> | |
<td>cell1</td> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |
<title>基本的html标签</title> | |
</head> | |
<body> | |
<h2>标题</h2> | |
<p>段落</p> | |
<a href="#">链接</a> | |
<a href="javascript:;">链接</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |
<title>我的第一个html文档</title> | |
</head> | |
<body> | |
<p>你好,html</p> | |
</body> | |
</html> |