0

I have a very basic website-scraper running on my rapsberry pi.

r = get(url)
with open('filename.html', 'w') as f:
        f.write(r.text)

Running it in the terminal works as expected. But running it via a cron job gives the following error (found it via mailx)

f.write(r.text)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 67005: ordinal not in range(128)

What causes the script to work when used via the terminal:

>python thescript.py

But it does not work using

30 9 * * * python /home/pi/thescript.py
rul30
  • 463
  • 1
  • 7
  • 17
  • This has nothing to do with `cron` – roganjosh Oct 11 '18 at 20:07
  • Any ideas what causes this behavior? – rul30 Oct 12 '18 at 04:50
  • It's likely that you don't have setup the Environment for `cron`. Read [where-can-i-set-environment-variables-that-crontab-will-use](https://stackoverflow.com/questions/2229825/where-can-i-set-environment-variables-that-crontab-will-use) – stovfl Oct 12 '18 at 06:42

0 Answers0