Final Project <<
Previous run
from browser import html
from browser import document
import random
brython_div = document["brython_div"]
url = "https://gist.githubusercontent.com/mdecourse/b11a88a98655d41055c47f08fe94788f/raw/8a27e6885ee1a5074bcf864d741679afeac796c4/2b_w2_stud_list.txt"
data = open(url).readlines()
# 檢查資料筆數, 第一筆為 title
#print(data)
#print(len(data))
data = data[1:]
#print(data)
# 根據 href 與 content 將 html 元件中的 anchor 插入頁面
def makeLink(href, content):
brython_div <= html.A(content, href=href)
#brython_div <= html.BR()
# 從學員資料中隨機取出 10 位學員的網頁進行查核
select = 10
random.shuffle(data)
data = data[:select]
course = "cad2021"
for i in range(len(data)):
num_github = data[i]
num = num_github.split("\t")[0]
account = num_github.split("\t")[1]
if account == "":
account = num
content = str(num)
hwhref = "https://"+ str(account) + ".github.io/"+course+ "_hw"
repohref = "https://github.com/"+ str(account) +"/"+course +"_hw"
brython_div <= "repo: "
makeLink(repohref, content)
brython_div <= " www: "
makeLink(hwhref, content)
brython_div <= html.BR()
Final Project <<
Previous