Not exactly sure how this should look, but I want this code to be written into a csv file. I've tried making taking the entire output and doing output.to_csv('output.csv') but I can't seem to get that to work.
import csv ;import requests
from bs4 import BeautifulSoup
import csv
import re
url_list = ['https://basketball.realgm.com/player/player/Summary/2',
'https://basketball.realgm.com/player/player/Summary/1']
for url in url_list:
r = requests.get(url)
soup = BeautifulSoup(r.text, 'html.parser')
player = soup.find_all('div', class_='wrapper clearfix container')[0]
playerprofile = re.sub(
r'\n\s*\n', r'\n', player.get_text().strip(), flags=re.M)
output = playerprofile + "\n"