縮排控制
上色語言
CTRL+F | 搜尋 |
CTRL+H | 取代 |
CTRL+Shift+P | 開啟指令介面 |
Esc | 離開目前功能 |
CTRL+Click | multiple selection |
HyperText Markup Language
超文字
標記
語言
<TAGNAME>EXAMPLE</TAGNAME>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
<TAGNAME>
<img>
<input>
<br>
<link>
<meta>
<source>
<!DOCTYPE>
Hello World!!!
I am new to HTML
<!DOCTYPE>
Hello World!!!<br>
I am new to HTML
<!DOCTYPE>
<h1>Hello World!!!</h1>
<p>I am new to HTML</p>
<!DOCTYPE>
<h1>heading1</h1>
<h2>heading2</h2>
<h3>heading3</h3>
<h4>heading4</h4>
<h5>heading5</h5>
<h6>heading6</h6>
<p>paragraph</p>
<!DOCTYPE>
<h1 style="color: red;">heading1</h1>
<h2 style="color: orange;">heading2</h2>
<h3 style="color: yellow;">heading3</h3>
<h4 style="color: green;">heading4</h4>
<h5 style="color: blue;">heading5</h5>
<h6 style="color: purple;">heading6</h6>
<p style="color: #808080;">paragraph</p>
<TAGNAME ATTRIBUTE="VALUE"></TAGNAME>
<!DOCTYPE>
<h1 style="color: red;text-align:center">heading1</h1>
<h2 style="color: orange;text-align:center">heading2</h2>
<h3 style="color: yellow;text-align:center">heading3</h3>
<h4 style="color: green;text-align:center">heading4</h4>
<h5 style="color: blue;text-align:center">heading5</h5>
<h6 style="color: purple;text-align:center">heading6</h6>
<p style="color: #808080;text-align:center">paragraph</p>
<!DOCTYPE>
<h1 style="color: red;text-align: center;border-style: solid;">heading1</h1>
<h2 style="color: orange;text-align: center;border-style: solid;">heading2</h2>
<h3 style="color: yellow;text-align: center;border-style: solid;">heading3</h3>
<h4 style="color: green;text-align: center;border-style: solid;">heading4</h4>
<h5 style="color: blue;text-align: center;border-style: solid;">heading5</h5>
<h6 style="color: purple;text-align: center;border-style: solid;">heading6</h6>
<p style="color: gray;text-align: center;border-style: solid;">paragraph</p>
<!DOCTYPE>
<style>
.text{
text-align: center;
border-style: solid;
}
</style>
<h1 class="text" style="color: red;">heading1</h1>
<h2 class="text" style="color: orange;">heading2</h2>
<h3 class="text" style="color: yellow;">heading3</h3>
<h4 class="text" style="color: green;">heading4</h4>
<h5 class="text" style="color: blue;">heading5</h5>
<h6 class="text" style="color: purple;">heading6</h6>
<p class="text" style="color: gray;">paragraph</p>
讓所有 class 是 text 的 element 都加上 "text-align: center;border-style: solid;"
<!DOCTYPE>
<style>
.text{
text-align: center;
border-style: solid;
}
.round{
border-radius: 100px;
}
</style>
<h1 class="text round" style="color: red;">heading1</h1>
<h2 class="text" style="color: orange;">heading2</h2>
<h3 class="text round" style="color: yellow;">heading3</h3>
<h4 class="text" style="color: green;">heading4</h4>
<h5 class="text round" style="color: blue;">heading5</h5>
<h6 class="text" style="color: purple;">heading6</h6>
<p class="text round" style="color: gray;">paragraph</p>
<!DOCTYPE>
<style>
.text{
text-align: center;
border-style: solid;
}
.round{
border-radius: 100px;
}
</style>
<h1 class="text round" style="color: red;">heading1</h1>
<h2 class="text" style="color: orange;">heading2</h2>
<h3 class="text round" style="color: yellow;">heading3</h3>
<h4 class="text" style="color: green;">heading4</h4>
<h5 class="text round" style="color: blue;">heading5</h5>
<h6 class="text" style="color: purple;">heading6</h6>
<p class="text round" style="color: gray;">paragraph</p>
CSS code
CSS selector
<!DOCTYPE html>
<ol>
<li>first</li>
<li>second</li>
<li>third</li>
</ol>
ordered list / list item
<!DOCTYPE html>
<ul>
<li>first</li>
<li>second</li>
<li>third</li>
</ul>
unordered list / list item
<a href="https://slides.com/thomaswang2003/web">learn web</a>
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
蛤?現在才講?
<!DOCTYPE html>
<html>
<head>
<title>jizz</title>
</head>
<body>
everything to be displayed on page
</body>
</html>
title
body
<head>
<meta charset="UTF-8">
<meta name="description" content="INFOR Web-frontend jizz">
<meta name="keywords" content="Sublime,HTML,CSS,Javascript,Web-crawling">
<meta name="author" content="Thomas Wang">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
Cascading Style Sheets
/* select by element name */
ELEMENT {...}
/* select by class */
.CLASS {...}
/* select by id */
#id {...}
/* select all */
* {...}
/* select by element name */
h1 {font-weight: 1000;}
/* select by class */
.center {text-align: center;}
/* select by id */
#box {background-color: red;}
/* select all */
* {font-family: 'Noto Sans TC';}
function double(x){
x=String(x);
return x+x;
}
console.log(double(7122))
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script>
var x=7122;
console.log(x);
// js code goes here
</script>
</body>
</html>
document.getElementById
document.getElementsByTag
document.getElementsByClassName
<!DOCTYPE html>
<html>
<body>
<h1 id="test">Testing Page</h1>
<script>
var ele = document.getElementById('test');
ele.innerHTML='Changed';
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h1 class="text">heading1</h1>
<h2 class="text">heading2</h2>
<h3 class="text">heading3</h3>
<h4 class="text">heading4</h4>
<h5 class="text">heading5</h5>
<h6 class="text">heading6</h6>
<p class="text">paragraph</p>
<script>
var eles = document.getElementsByClassName('text');
console.log(eles.length);
for(var i=0;i<eles.length;i++)
eles[i].innerHTML='Changed';
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h1 class="text">heading1</h1>
<h2 class="text">heading2</h2>
<h3 class="text">heading3</h3>
<h4 class="text">heading4</h4>
<h5 class="text">heading5</h5>
<h6 class="text">heading6</h6>
<p class="text">paragraph</p>
<button onclick="change();">Change</button>
<script>
function change(){
var eles = document.getElementsByClassName('text');
console.log(eles.length);
for(var i=0;i<eles.length;i++)
eles[i].innerHTML='Changed';
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h1 class="text">heading1</h1>
<h2 class="text">heading2</h2>
<h3 class="text">heading3</h3>
<h4 class="text">heading4</h4>
<h5 class="text">heading5</h5>
<h6 class="text">heading6</h6>
<p class="text">paragraph</p>
<button id="btn">Change</button>
<script>
function change(){
var eles = document.getElementsByClassName('text');
console.log(eles.length);
for(var i=0;i<eles.length;i++)
eles[i].innerHTML='Changed';
}
document.getElementById('btn').addEventListener('click',change);
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h1 class="text">heading1</h1>
<h2 class="text">heading2</h2>
<h3 class="text">heading3</h3>
<h4 class="text">heading4</h4>
<h5 class="text">heading5</h5>
<h6 class="text">heading6</h6>
<p class="text">paragraph</p>
<button id="btn">Change</button>
<script>
function double(x){
x=String(x);
return x+x;
}
function change(){
var eles = document.getElementsByClassName('text');
console.log(eles.length);
for(var i=0;i<eles.length;i++)
eles[i].innerHTML=double(eles[i].innerHTML);
}
document.getElementById('btn').addEventListener('click',change);
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h1 class="text">heading1</h1>
<h2 class="text">heading2</h2>
<h3 class="text">heading3</h3>
<h4 class="text">heading4</h4>
<h5 class="text">heading5</h5>
<h6 class="text">heading6</h6>
<p class="text">paragraph</p>
<button id="btn1" onclick="change();">Change</button>
<button id="btn2" onclick="hide(this);">Hide</button>
<script>
function double(x){
x=String(x);
return x+x;
}
function change(){
var eles = document.getElementsByClassName('text');
console.log(eles.length);
for(var i=0;i<eles.length;i++)
eles[i].innerHTML=double(eles[i].innerHTML);
}
function hide(x){
if(x.innerHTML=='Hide'){
x.innerHTML='Show';
var eles = document.getElementsByClassName('text');
console.log(eles.length);
for(var i=0;i<eles.length;i++)
eles[i].style.display='none';
}else{
x.innerHTML='Hide';
var eles = document.getElementsByClassName('text');
console.log(eles.length);
for(var i=0;i<eles.length;i++)
eles[i].style.display='block';
}
}
</script>
</body>
</html>
網頁爬蟲
import requests
response=requests.get('https://tioj.ck.tp.edu.tw')
print(response)
print(response.text)
缺了css
但我們不在乎
from bs4 import BeautifulSoup as bs
code='<div><p>bs4</p></div>'
html=bs(code,'html.parser')
print(html.prettify())
print(html.select('div > p'))
print(html.select('div > p')[0].text)