I have tried the following code and this function doesn't work giving me an error.
"AttributeError: 'NoneType' object has no attribute 'findNextSiblings'"
What can I do solve this error ?
I tried removing the
w_span variables and calling the
soup.findNextSibling function in the loop instead of
h_span.findNextSibling and it just returns an empty string , code does work.
from selenium import webdriver from bs4 import BeautifulSoup import requests import os driver = webdriver.Chrome(executable_path= r'E:/Summer/FirstThings/Web scraping (bucky + pdf)/webscraping/tutorials-master/chromedriver.exe') url = 'https://www.nba.com/players/aron/baynes/203382' driver.get(url) soup = BeautifulSoup(driver.page_source , 'lxml') height = '' h_span = soup.find('p', string = 'HEIGHT') for span in h_span.findNextSiblings(): height = height + span.text weight = '' w_span = soup.find('p', string = 'WEIGHT') for span in w_span.findNextSiblings(): weight = weight + span.text born = '' b_span = soup.find('p', string = 'BORN') for span in b_span.findNextSiblings(): born = born + span.text print(height) print("") print(weight) print("") print(born) driver.__exit__()
It should return the player height weight and born info in text format with the titles itself.