煮豆燃豆萁...means what

七步诗

煮豆燃豆萁
豆在釜中泣
本是同根生
相煎何太急

story

The king is trying to kill his brother and gave mercy only if the brother made a poem in 7 steps that can change his mind. And it happened. Burning the dried beanstalks to cook beans, beans are crying in the pot, we are from the same family same root, why rush to kill each other

BeautifulSoup解析器lxml、html5lib和默认解析器区别

使用BeautifulSoup 解析网页学简笔画网chengyu/19601.html, 发现常用的lxml解析器解析缺失<div class="footer">内容, 决定一探究竟,记录下结论

lxml

  • 解析器速度最快, 能默认处理类似<a></b>这类错误,自动识别为<a></a>
  • 对于简单的不正确闭合能自动纠正,稍微复杂的闭合错误会出现解析失败内容缺失的情况,复杂情况未正确闭合内容会默认剔除
  • lxml会读取meta中的charset编码类型,自动转换为utf-8,当设置编码与实际编码不一致也会导致内容缺失,如指定了编码<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />, 实际内容非gb2312编码,遇到汉字字符解析失败,内容就只有前几行兼容ascii编码内容

hmtl5lib

  • 安装pip3 install html5lib
  • 对未正确关闭标签,有较好的兼容性
  • 对charset不符实际编码会按指定编码强制转换,与lxml省略不一样

默认html.parser

  • 解析速度不如前两者
  • 不自动不全<head></head> 基本Doc 元素
  • 不识别 meta编码,统一按utf-8读取,对中文网站解析不友好

解析结果对比 html5lib (左) lxml(右)

请输入图片描述请输入图片描述

ipython崩溃异常退出解决办法

ipython

  • ipython是一个非常实用的交互软件, 能帮助python coder快速实时的看到运行结果,但随着版本更新,不可避免出现一些意想不到的情况,比如ipython3.6.8之后的版本安装总会遇到'''AttributeError: 'TypeError' object has no attribute 'tb_frame'''这样的报错
  • 总结解决办法, 如果有其它项目或工程依赖jedi,请谨慎删除
    '''

pip3 uninstall jedi --yes
'''

Python离线安装模块

pip离线安装

pip 下载模块相关文件

pip3  download   bs4 Path asyncio argparse

离线安装

pip3 install --no-index --find-links='path/'  bs4 Path asyncio argparse

宝塔环境下acme脚本使用

宝塔环境命令行更新HTTPS证书

  • acme_v2.py

    • /www/server/panel/class/acme_v2.py文件解读略
    • 使用方法详见if __name__ == '__main__'中语句
    • 使用示例
    python /www/server/panel/class/acme_v2.py --domain 域名1,域名2 --type http --path 网址根路径