提交 a989f68b 编写于 作者: F feilong

添加网络爬虫题目

上级 fc23aaab
...@@ -3,5 +3,6 @@ ...@@ -3,5 +3,6 @@
"author": "huanhuilong", "author": "huanhuilong",
"source": "helloworld.md", "source": "helloworld.md",
"depends": [], "depends": [],
"type": "code_options" "type": "code_options",
"notebook_enable": true
} }
\ No newline at end of file
{ {
"author": "huanhuilong", "author": "huanhuilong",
"source": "class.md", "source": "class.md",
"depends": [], "depends": [],
"exercise_id": 26, "exercise_id": 26,
"type": "code_options" "type": "code_options",
"notebook_enable": true
} }
\ No newline at end of file
{ {
"author": "huanhuilong", "author": "huanhuilong",
"source": "function.md", "source": "function.md",
"depends": [], "depends": [],
"exercise_id": 28, "exercise_id": 28,
"type": "code_options" "type": "code_options",
"notebook_enable": true
} }
\ No newline at end of file
{ {
"author": "huanhuilong", "author": "huanhuilong",
"source": "process.md", "source": "process.md",
"depends": [], "depends": [],
"exercise_id": 27, "exercise_id": 27,
"type": "code_options" "type": "code_options",
"notebook_enable": true
} }
\ No newline at end of file
{ {
"author": "huanhuilong", "author": "huanhuilong",
"source": "install.md", "source": "install.md",
"depends": [], "depends": [],
"exercise_id": 31, "exercise_id": 31,
"type": "code_options" "type": "code_options",
"notebook_enable": true
} }
\ No newline at end of file
{ {
"author": "huanhuilong", "author": "huanhuilong",
"source": "run.md", "source": "run.md",
"depends": [], "depends": [],
"exercise_id": 32, "exercise_id": 32,
"type": "code_options" "type": "code_options",
"notebook_enable": true
} }
\ No newline at end of file
{ {
"author": "huanhuilong", "author": "huanhuilong",
"source": "ide.md", "source": "ide.md",
"depends": [], "depends": [],
"exercise_id": 30, "exercise_id": 30,
"type": "code_options" "type": "code_options",
"notebook_enable": true
} }
\ No newline at end of file
{ {
"author": "huanhuilong", "author": "huanhuilong",
"source": "style.md", "source": "style.md",
"depends": [], "depends": [],
"exercise_id": 29, "exercise_id": 29,
"type": "code_options" "type": "code_options",
"notebook_enable": true
} }
\ No newline at end of file
{ {
"author": "huanhuilong", "author": "huanhuilong",
"source": "import_lib.md", "source": "import_lib.md",
"depends": [], "depends": [],
"exercise_id": 163, "exercise_id": 163,
"type": "code_options" "type": "code_options",
"notebook_enable": true
} }
\ No newline at end of file
{ {
"author": "huanhuilong", "author": "huanhuilong",
"source": "import_other_module.md", "source": "import_other_module.md",
"depends": [], "depends": [],
"exercise_id": 164, "exercise_id": 164,
"type": "code_options" "type": "code_options",
"notebook_enable": true
} }
\ No newline at end of file
{ {
"author": "huanhuilong", "author": "huanhuilong",
"source": "import_relative.md", "source": "import_relative.md",
"depends": [], "depends": [],
"exercise_id": 165, "exercise_id": 165,
"type": "code_options" "type": "code_options",
"notebook_enable": true
} }
\ No newline at end of file
{ {
"author": "huanhuilong", "author": "huanhuilong",
"source": "step.md", "source": "step.md",
"depends": [], "depends": [],
"exercise_id": 83, "exercise_id": 83,
"type": "code_options" "type": "code_options",
"notebook_enable": true
} }
\ No newline at end of file
{ {
"author": "huanhuilong", "author": "huanhuilong",
"source": "call.md", "source": "call.md",
"depends": [], "depends": [],
"exercise_id": 197, "exercise_id": 197,
"type": "code_options" "type": "code_options",
"notebook_enable": true
} }
\ No newline at end of file
{ {
"author": "huanhuilong", "author": "huanhuilong",
"source": "fact1.md", "source": "fact1.md",
"depends": [], "depends": [],
"exercise_id": 190, "exercise_id": 190,
"type": "code_options" "type": "code_options",
"notebook_enable": true
} }
\ No newline at end of file
{ {
"author": "huanhuilong", "author": "huanhuilong",
"source": "fact2.md", "source": "fact2.md",
"depends": [], "depends": [],
"exercise_id": 244, "exercise_id": 244,
"type": "code_options" "type": "code_options",
"notebook_enable": true
} }
\ No newline at end of file
{ {
"author": "huanhuilong", "author": "huanhuilong",
"source": "fibonacci1.md", "source": "fibonacci1.md",
"depends": [], "depends": [],
"exercise_id": 201, "exercise_id": 201,
"type": "code_options" "type": "code_options",
"notebook_enable": true
} }
\ No newline at end of file
{ {
"author": "huanhuilong", "author": "huanhuilong",
"source": "fibonacci2.md", "source": "fibonacci2.md",
"depends": [], "depends": [],
"exercise_id": 239, "exercise_id": 239,
"type": "code_options" "type": "code_options",
"notebook_enable": true
} }
\ No newline at end of file
{ {
"author": "huanhuilong", "author": "huanhuilong",
"source": "helloworld2.md", "source": "helloworld2.md",
"depends": [], "depends": [],
"exercise_id": 166, "exercise_id": 166,
"type": "code_options" "type": "code_options",
"notebook_enable": true
} }
\ No newline at end of file
{ {
"author": "huanhuilong", "author": "huanhuilong",
"source": "hash_key_value_set.py", "source": "hash_key_value_set.py",
"depends": [ "depends": [
"key_value_set.py" "key_value_set.py"
], ],
"exercise_id": 169, "exercise_id": 169,
"type": "code_options" "type": "code_options",
"notebook_enable": true
} }
\ No newline at end of file
{ {
"author": "huanhuilong", "author": "huanhuilong",
"source": "hash_key_value_set_by_compose.py", "source": "hash_key_value_set_by_compose.py",
"depends": [ "depends": [
"key_value_set.py" "key_value_set.py"
], ],
"exercise_id": 168, "exercise_id": 168,
"type": "code_options" "type": "code_options",
"notebook_enable": true
} }
\ No newline at end of file
{ {
"author": "huanhuilong", "author": "huanhuilong",
"source": "key_value_set.md", "source": "key_value_set.md",
"depends": [], "depends": [],
"exercise_id": 167, "exercise_id": 167,
"type": "code_options" "type": "code_options",
"notebook_enable": true
} }
\ No newline at end of file
...@@ -2,5 +2,7 @@ ...@@ -2,5 +2,7 @@
"source": "calc.py", "source": "calc.py",
"depends": [], "depends": [],
"exercise_id": 76, "exercise_id": 76,
"type": "code_options" "type": "code_options",
"notebook_enable": true,
"author": "feilong"
} }
\ No newline at end of file
{ {
"author": "HansBug", "author": "HansBug",
"source": "iter.md", "source": "iter.md",
"depends": [], "depends": [],
"exercise_id": 190, "exercise_id": "4ded2d6929124ddd90f409a72eb073cc",
"type": "code_options" "type": "code_options",
} "notebook_enable": true
}
\ No newline at end of file
{ {
"author": "zxm2015", "author": "zxm2015",
"source": "dynamic_page.md", "source": "dynamic_page.md",
"depends": [], "depends": [],
"type": "code_options" "type": "code_options",
"exercise_id": "d723ad753e0f4367932a9436f8732ec8",
"notebook_enable": true
} }
\ No newline at end of file
{ {
"author": "zxm2015", "author": "zxm2015",
"source": "simulate_login.md", "source": "simulate_login.md",
"depends": [], "depends": [],
"type": "code_options" "type": "code_options",
} "exercise_id": "b909e9d8af9c44498ffc0519d7b8be62",
"notebook_enable": true
}
\ No newline at end of file
{ {
"author": "zxm2015", "author": "zxm2015",
"source": "selenium.md", "source": "selenium.md",
"depends": [], "depends": [],
"type": "code_options" "type": "code_options",
} "exercise_id": "fa67f7b6cfb94d4aa5048c0748220313",
"notebook_enable": true
}
\ No newline at end of file
{ {
"author": "zxm2015", "author": "zxm2015",
"source": "pyspider.md", "source": "pyspider.md",
"depends": [], "depends": [],
"type": "code_options" "type": "code_options",
} "exercise_id": "2a356f5e71174f599bfea527cd062057",
"notebook_enable": true
}
\ No newline at end of file
{ {
"author": "zxm2015", "author": "zxm2015",
"source": "verification_code.md", "source": "verification_code.md",
"depends": [], "depends": [],
"type": "code_options" "type": "code_options",
} "exercise_id": "9ae36338010949038ac029a0396b9d10",
"notebook_enable": true
}
\ No newline at end of file
{ {
"author": "huanhuilong", "author": "huanhuilong",
"source": "loc.md", "source": "loc.md",
"depends": [], "depends": [],
"exercise_id": 121, "exercise_id": 121,
"type": "code_options" "type": "code_options",
"notebook_enable": true
} }
\ No newline at end of file
{ {
"author": "huanhuilong", "author": "huanhuilong",
"source": "stat.md", "source": "stat.md",
"depends": [], "depends": [],
"exercise_id": 125, "exercise_id": 125,
"type": "code_options" "type": "code_options",
"notebook_enable": true
} }
\ No newline at end of file
...@@ -16,9 +16,11 @@ handler.setFormatter(formatter) ...@@ -16,9 +16,11 @@ handler.setFormatter(formatter)
logger.addHandler(handler) logger.addHandler(handler)
repo = git.Repo(".") repo = git.Repo(".")
def user_name(): def user_name():
return repo.config_reader().get_value("user", "name") return repo.config_reader().get_value("user", "name")
def load_json(p): def load_json(p):
with open(p, 'r') as f: with open(p, 'r') as f:
return json.loads(f.read()) return json.loads(f.read())
...@@ -100,11 +102,13 @@ class TreeWalker: ...@@ -100,11 +102,13 @@ class TreeWalker:
for index, chapter in enumerate(level_node["children"]): for index, chapter in enumerate(level_node["children"]):
chapter_title = list(chapter.keys())[0] chapter_title = list(chapter.keys())[0]
chapter_node = list(chapter.values())[0] chapter_node = list(chapter.values())[0]
chapter_path = os.path.join(level_path, f"{index + 1}.{chapter_title}") chapter_path = os.path.join(
level_path, f"{index + 1}.{chapter_title}")
self.load_sections(chapter_path, chapter_node) self.load_sections(chapter_path, chapter_node)
for index, section_node in enumerate(chapter_node["children"]): for index, section_node in enumerate(chapter_node["children"]):
section_title = list(section_node.keys())[0] section_title = list(section_node.keys())[0]
full_path = os.path.join(chapter_path, f"{index + 1}.{section_title}") full_path = os.path.join(
chapter_path, f"{index + 1}.{section_title}")
if os.path.isdir(full_path): if os.path.isdir(full_path):
self.check_section_keywords(full_path) self.check_section_keywords(full_path)
self.ensure_exercises(full_path) self.ensure_exercises(full_path)
...@@ -322,7 +326,8 @@ class TreeWalker: ...@@ -322,7 +326,8 @@ class TreeWalker:
config["export"] = export config["export"] = export
if flag: if flag:
dump_json(os.path.join(section_path, "config.json"), config, True, True) dump_json(os.path.join(section_path, "config.json"),
config, True, True)
for e in config.get("export", []): for e in config.get("export", []):
full_name = os.path.join(section_path, e) full_name = os.path.join(section_path, e)
...@@ -370,6 +375,6 @@ class TreeWalker: ...@@ -370,6 +375,6 @@ class TreeWalker:
def check_section_keywords(self, full_path): def check_section_keywords(self, full_path):
config = self.ensure_section_config(full_path) config = self.ensure_section_config(full_path)
if not config.get("keywords", []): # if not config.get("keywords", []):
self.logger.error(f"节点 [{full_path}] 的关键字为空,请修改配置文件写入关键字") # self.logger.error(f"节点 [{full_path}] 的关键字为空,请修改配置文件写入关键字")
sys.exit(1) # sys.exit(1)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册