[python] snippet to look into html parse tree
This commit is contained in:
parent
edd2259e45
commit
10bb0e2711
|
@ -1,7 +1,7 @@
|
|||
# Web
|
||||
coq/*.html
|
||||
coq/*.js
|
||||
coq/*.css
|
||||
coq/**/*.html
|
||||
coq/**/*.js
|
||||
coq/**/*.css
|
||||
|
||||
# Haskell
|
||||
*.hi
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
#+TITLE: Bluespec SystemVerilog
|
||||
|
||||
- [[./rca/][w-bit ripple carry adder]]
|
|
@ -0,0 +1,23 @@
|
|||
"""
|
||||
Find all links (anchor tags) in an html snippet
|
||||
"""
|
||||
|
||||
# https://docs.python.org/3/library/html.parser.html
|
||||
|
||||
from html.parser import HTMLParser
|
||||
|
||||
class MyHTMLParser(HTMLParser):
|
||||
def handle_starttag(self, tag, attrs):
|
||||
if tag == "a":
|
||||
for attr in attrs:
|
||||
if attr[0] == "href":
|
||||
print(attr[1])
|
||||
|
||||
parser = MyHTMLParser()
|
||||
|
||||
with open("../build/html/index.html") as fin:
|
||||
parser.feed(fin.read())
|
||||
|
||||
# with MyHTMLParser as parser:
|
||||
# parser.feed('<html><head><title>Test</title></head>'
|
||||
# '<body><h1>Parse <a href="hi">me!</a></h1></body></html>')
|
|
@ -1,18 +1,18 @@
|
|||
from turtle import *
|
||||
# https://www.youtube.com/watch?v=MO_euV5YwVc
|
||||
|
||||
def polygon(n, sidelen):
|
||||
def polygon(tur, n, sidelen):
|
||||
for i in range(n):
|
||||
forward(sidelen)
|
||||
right(360/n)
|
||||
tur.forward(sidelen)
|
||||
tur.right(360/n)
|
||||
|
||||
# Set pen-colour to red and fill-colour to yellow
|
||||
color('red', 'yellow')
|
||||
|
||||
t = Turtle()
|
||||
# t.speed("fastest")
|
||||
# t.hideturtle()
|
||||
polygon(6, 100)
|
||||
t.speed("fastest")
|
||||
t.hideturtle()
|
||||
polygon(t, 6, 100)
|
||||
|
||||
|
||||
input()
|
||||
|
|
Loading…
Reference in New Issue