小编Die*_*ego的帖子

在 chrome 中自动打印/保存网页为 pdf - python 2.7

我正在尝试在 chrome 中自动打印保存网页为 pdf。

我已经检查了 webbrowser 模块,但它似乎不是用于此目的。

我探索了 wkhtmltopdf 作为替代方案,但在下载文件时,它似乎被病毒感染了。

感谢您的建议。

html automation pdf-generation python-2.7

8
推荐指数
2
解决办法
2万
查看次数

在HTML中查找和替换字符串

从这个HTML代码:

<p class="description" dir="ltr">Name is a fine man. <br></p>
Run Code Online (Sandbox Code Playgroud)

我正在寻找使用以下代码替换"名称":

target = soup.find_all(text="Name")
for v in target:
    v.replace_with('Id')
Run Code Online (Sandbox Code Playgroud)

我想要的输出是:

<p class="description" dir="ltr">Id is a fine man. <br></p>
Run Code Online (Sandbox Code Playgroud)

当我:

print target
[]
Run Code Online (Sandbox Code Playgroud)

为什么不找到"名字"?

谢谢!

html python beautifulsoup python-2.7

1
推荐指数
1
解决办法
3937
查看次数