webtools

utils_html

get_browser_path

dramkit.webtools.utils_html.get_browser_path(browser='chrome', logger=None)
获取浏览器的安装路径
param browser为浏览器名称,可选dramkit.webtools.utils_html.BROWSER_REGS中的key值

open_html

dramkit.webtools.utils_html.open_html(path_html, browser=None, logger=None)
调用浏览器打开html文档
path_html为html文档路径
browser支持浏览器名称或浏览器路径

html_to_soup

dramkit.webtools.utils_html.html_to_soup(path_html, encoding=None)
将HTML文档读取成BeautifulSoup数据格式
path_html为HTML文件路径
返回Soup对象

soup_to_html

dramkit.webtools.utils_html.soup_to_html(Soup, path_html, encoding=None)
将BeautifulSoup对象写入HTML文档
Soup为需要写入的BeautifulSoup对象
path_html为HTML文件存放路径

insert_src_head_end

dramkit.webtools.utils_html.insert_src_head_end(path_html, path_src, encoding=None)
在HTML文档中添加一个引用脚本的script标签,添加位置为head标签的最后
path_html为HTML文件路径
path_src为引用的js数据文件路径和名称

del_js_head_end

dramkit.webtools.utils_html.del_js_head_end(path_html, encoding=None)

删除HTML文档head部分的最后一个标签

get_head_num

dramkit.webtools.utils_html.get_head_num(path_html, encoding=None)

获取head标签子标签的个数