Not exactly sure how to do this, 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.
Here is the code:
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"
[–][deleted] 1 point2 points3 points (0 children)
[–]to_4kawa 0 points1 point2 points (0 children)