Python Bytes - Web Scraping Beautiful Soup Export Data Dataframe to Excel Code in Description

preview_player
Показать описание
#Coded By Andrew C
#Youtube does not allow angled brackets in video titles or descriptions so I replaced it with actual text. You will need to replace it back to original code in the video to execute.

from subprocess import call, sys

def install(package):
call([
"-m",
"pip",
"--disable-pip-version-check",
"-q",
"install",
package
])

install('beautifulsoup4')
install('requests')
install('pandas')

from bs4 import BeautifulSoup
import requests
import re

print(title_text)
print("=" * len(title_text))
print()

#Pull text from hyper links
links_with_text = []

#Pull data from tables

#Clean up data
cleanup = links_with_text[3:-7]
position = cleanup[0:-1:3]
names = cleanup[1::3]
school = cleanup[2::3]
height = heightweightclean[::2]
weight = heightweightclean[1::2]
teamnumber_clean = teamnumber_clean[1::3]

import pandas as pd
roster = pd.DataFrame({
"Name": names,
"No.": teamnumber_clean,
"Position": position,
"School": school,
"Height": height,
"Weight": weight,
"Birth Day": birth_clean
})

print(roster)

#Export data to CSV

#datascience #python #coding
Рекомендации по теме
Комментарии
Автор

May i have more explanation about how you export to excel please ?

mambamentally