Beginner: Trying to create a new csv every hour


  • I am trying to create a csv file every hour that contains the headlines from CNN
  • I am not able to deploy it. The deployment fails before there are any logs
  • I am a total beginner, so I am sure I am missing something very basic

Repl link:

import os
import requests
from bs4 import BeautifulSoup
import csv
from datetime import datetime
import time

url = ""

def scrape_headlines():
    now =
    # Format date and time with leading zeros
    date = "{:02d}-{:02d}-{:02d}".format(now.year, now.month,
    time = "{:02d}{:02d}".format(now.hour, now.minute)
    folder_name = "cnn"
    if not os.path.exists(folder_name):
    filename = os.path.join(folder_name, "{}-{}.csv".format(date, time))
    response = requests.get(url)
    soup = BeautifulSoup(response.text, "html.parser")
    headlines = []
    for headline in soup.find_all("span", {"data-editable": "headline"}):
    with open(filename, "w", newline="") as csvfile:
        writer = csv.writer(csvfile)
        writer.writerow(["Headline", "Rank"])
        rank = 1
        for headline in headlines:
            writer.writerow([headline, rank])
            rank += 1

# Add code to run at the top of the hour
while True:
    current_time ="%M")
    if current_time == "00":
    time.sleep(60)  # Sleep for 1 minute

Sorry for the horrible formatting!

Hi @makanamini , welcome to the forums!
Can you format it like this:

1 Like

Hi there. Did you mean to deploy this via on-demand deployments? It should work if you deploy to a reserved VM. Select the “Background Worker” option.

One limitation of our current product is changes you make to the deployed VM’s filesystem will not persist with your development Repl.

In other words, even if you are successful in deploying the repl, the csv files you want won’t save back to the original development Repl.

We’ll have a solution for this soon.