С этим кодом я могу получить только Атлантический дивизион, но не другие дивизии.Я не могу понять тег HTML для других подразделений.Вот ссылка на исходный код с веб-сайта, который я собираю в Интернете: view-source: https://www.basketball -reference.com / league / NBA_2019_per_game.html
import os
import time
from selenium import webdriver
from bs4 import BeautifulSoup as soup
driver = webdriver.Chrome()
driver.get("https://www.basketball-reference.com/leagues/NBA_2019_per_game.html")
page = soup(driver.page_source, "html.parser")
Atlantic = page.find('tr').find_parent().get_text()
Central = page.find('tr').find_parent().get_text()
#Central = page.find('tr').find_parent().get_text()
Southeast = page.find('tr').find_parent().get_text()
Northwest = page.find('tr').find_parent().get_text()
Pacific = page.find('tr').find_parent().get_text()
Southwest = page.find('tr').find_parent().get_text()
View_Atlantic = open('Atlantic_Division.txt','a')
View_Atlantic.write(Atlantic)
View_Atlantic.close()
View_Central = open('Central_Division.txt','a')
View_Central.write(Central)
View_Central.close()
View_Southeast = open('Southeast_Division.txt','a')
View_Southeast.write(Southeast)
View_Southeast.close()
View_Northwest = open('Northwest_Division.txt','a')
View_Northwest.write(Northwest)
View_Northwest.close()
View_Pacific = open('Pacific_Division.txt', 'a')
View_Pacific.write(Pacific)
View_Pacific.close()
View_Southwest = open('Southwest_Division.txt', 'a')
View_Southwest.write(Southwest)
View_Southwest.close()
driver.quit()
while True:
main = input("Which NBA division would you like to view?\n" +
'1. Atlantic Division\n2 Central Division\n3 Southeast Division\n4 Northwest Division\n5 Pacific Division\n6 Southwest Division \n7 Quit')
if main == '1':
View_Atlantic = open('Atlantic_Division.txt' , 'r')
lines = View_Atlantic.read()
print(lines)
View_Atlantic.close()
if main == '2':
View_Central = open('Central_Division.txt', 'r')
lines = View_Central.read()
print(lines)
View_Central.close()
if main == '3':
View_Southeast = open('Southeast_Division.txt', 'r')
lines = View_Southeast.read()
print(lines)
View_Southeast.close()
if main == '4':
View_Northwest = open('Northwest-Division.txt', 'r')
lines = View_Northwest.read()
print(lines)
View_Northwest.close()
if main == '5':
View_Pacific = open('Pacific_Division.txt', 'r')
lines = View_Pacific.read()
print(lines)
View_Pacific.close()
if main == '6':
View_Southwest = open('Southwest_Division.txt','r')
lines = View_Southwest.read()
print(lines)
View_Southwest.close()
if main == '7':
print('Bye!')
break
Я хочучтобы иметь возможность отображать команду НБА и отчет команды, выбрав определенное подразделение НБА.