Forums

write to .txt file not working

I want to run a script that simply writes some text into a .txt file

this is my code:

with open("/home/exec85/scrape/pc.txt", "a") as f:

f.write(f"{list_all_results}")

I want to write the data of some webscraping into a .txt file. But the file is just empty. Running this on my PC works as intended. What am I missing?

Check that you actually have something in list_all_results to write to the file.

Thats an issue as well, because for some reason my web scraping script is not working on pythonanywhere, while it runs smooth on my local machine. here is the shared link to my code: https://www.pythonanywhere.com/user/exec85/shares/10476452fd194c0e830d9fd5d3523f26/

You're on a free account. Free accounts can only access sites on our whitelist. We can only put sites on the whitelist if they have a publicly documented API. Send us a link to the API documentation for the site you're trying to access and we'll consider it for the whitelist.

ok got it I had to get a "Hacker" plan :-) Free plan is not allowing external scraping ;-)

no worris glenn, I like your service and I have now issues with getting a paid plan.

Thanks!