open .txt file and save output in csv file

Solution 1:

you code isn't working because inside URL is all the URL. you need to run one by one:

import requests as rq
from bs4 import BeautifulSoup as bs
with open(r'urls.txt', 'r') as f:
    urls = f.readlines()
with open('output1.csv', 'w', newline='') as f:
    for url in urls:
        request = rq.get(str(url))
        soup = bs(request.text, 'html.parser')
        title = soup.findAll('title')
        pdtitle = {}
        for pdtitle in title:
            pdtitle.append(pdtitle.text)
    f.write(f'{pdtitle}')