python - f.write(r.text) 停止在 cron-job 中工作
问题描述
我在我的 rapsberry pi 上运行了一个非常基本的网站抓取工具。
r = get(url)
with open('filename.html', 'w') as f:
f.write(r.text)
在终端中运行它可以按预期工作。但是通过 cron 作业运行它会出现以下错误(通过 mailx 找到)
f.write(r.text)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 67005: ordinal not in range(128)
通过终端使用时导致脚本工作的原因:
>python thescript.py
但它不起作用
30 9 * * * python /home/pi/thescript.py
解决方案
推荐阅读
- daterangepicker - 同时显示预定义的范围选项和日历 (daterangepicker.js)
- ios - 如何在此扩展程序中创建一个按钮,在不使用操作按钮的情况下在主应用程序中打开特定视图?
- swiftui - 如何在 ScrollView 中执行视图的动画转换?
- pandas - DataFrame 的反向滚动平均值
- c# - 有没有办法在运行时更改字符串属性“包含”的值?
- c# - 为 where 子句投射指南时遇到问题
- php - 用 php 处理 MVC 模式中的请求
- ios - 使用 TabBarViewController 呈现 NavigationController 无法以编程方式选择索引
- excel - 如何在excel中将重复值转换为唯一值
- python - 打开多个excel文件,打开每个文件上的每张表,并保存图片