来源博客:【Harryの心阁】
题目开源
来自:前端3+1,每天更新一题 有html,css,javascript,软技能
python代码
# -*-coding:utf8 -*-
import os, requests, json
# 获取题目到title.json文件中
def getData():
res = requests.get('http://api.h-camel.com/api?mod=interview&ctr=issues&act=history').json()
with open('title.json', 'w+', encoding='UTF-8') as f:
f.write(json.dumps(res, ensure_ascii=False))
f.close()
def postTitle():
with open('title.json', encoding='UTF-8') as f:
res = json.loads(f.read())['result'][f'{dayN}_']
if len(res) == 4:
backTitle(res, 'html', 'css', 'js', 'skill')
else:
backTitle(res, 'html', 'css', 'js')
def backTitle(dataList, *args):
for index, item in enumerate(args):
title = f'第{dayN}天问题:' + dataList[item]['title']
if dayN <= 11:
print(f'{title}\n链接地址:http://www.h-camel.com/show/{(int(dayN) - 1) * len(args) + index + 1}.html')
else:
print(f'{title}\n链接地址:http://www.h-camel.com/show/{33 + (int(dayN) - 12) * len(args) + index + 1}.html')
if __name__ == "__main__":
# 题目文件
folder = os.path.exists('title.json')
dayN = 10 # 定义全局变量 天数
if folder == False:
getData()
postTitle() # 获取题目,改变参数 表示天数
结果演示
第10天问题:viewport常见设置都有哪些?
链接地址:http://www.h-camel.com/show/28.html
第10天问题:对比下px、em、rem有什么不同?
链接地址:http://www.h-camel.com/show/29.html
第10天问题:简要描述下什么是回调函数并写一个例子出来
链接地址:http://www.h-camel.com/show/30.html