commit
b8d53d910d
@ -0,0 +1,12 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Hello World</title>
|
||||||
|
</head>
|
||||||
|
<html>
|
||||||
|
<body bgcolor="yellow">
|
||||||
|
<h1 align="center">这是一个一级标题</h1>
|
||||||
|
<p>这是第1个段落。</p>
|
||||||
|
<p>这是第2个段落。</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,28 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from pyquery import PyQuery as pq
|
||||||
|
|
||||||
|
f = open("step1/index.html", encoding='utf-8')
|
||||||
|
# f = open("../step1/result.html", encoding='utf-8')
|
||||||
|
|
||||||
|
html = f.read()
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
doc = pq(html)
|
||||||
|
|
||||||
|
tag = input()
|
||||||
|
|
||||||
|
result = ''
|
||||||
|
if tag == 'h1' or 'p':
|
||||||
|
result = doc(tag).text()
|
||||||
|
|
||||||
|
if tag == 'align':
|
||||||
|
h1Align= doc('h1').attr('align')
|
||||||
|
pAlign= doc('p').attr('align')
|
||||||
|
result = (h1Align and pAlign)
|
||||||
|
|
||||||
|
if tag == 'bgcolor':
|
||||||
|
result = doc('body').attr('bgcolor')
|
||||||
|
|
||||||
|
# print(result),
|
||||||
|
print (result, end='')
|
Loading…
Reference in new issue