вы можете сделать, как указано выше, используя open(file, 'a')
.Или то, что мне нравится делать, это добавлять все в таблицу, а затем записывать все как файл.
import requests
import bs4
import pandas as pd
results = pd.DataFrame()
daa = ['https://old.reddit.com/r/Games/comments/a2p1ew/', 'https://old.reddit.com/r/Games/comments/9zzo0e/', 'https://old.reddit.com/r/Games/comments/a31a6q/', ]
for y in daa:
w=1
uClient = requests.get(y, headers = {'User-agent': 'your bot 0.1'})
page_soup = bs4.BeautifulSoup(uClient.content, "html.parser")
time= page_soup.findAll("p", {"class":"tagline"})[0].time.get('datetime').replace('-', '')
temp_df = pd.DataFrame([[y, time]], columns=['url','time'])
results = results.append(temp_df).reset_index(drop = True)
result.to_csv('path/to_file.csv', index=False)