Answer the question
In order to leave comments, you need to log in
Find_all None fails to parse what to do?
import requests
from bs4 import BeautifulSoup
def get_html(url):
r = requests.get(url)
return r.text
def get_all_links(html):
soup = BeautifulSoup(html, 'lxml')
spans = soup.find('div', attrs = { ' class ' : 'line__wrapper ps ps--active-y' })
span_s = spans.find_all('span', class_='line-event__name')
links = []
for span in span_s:
a = span.find('a').get('href')
links.append(a)
return links
def main():
url = 'https://betcity.ru/ru/live/soccer/'
all_links = get_all_links( get_html(url) )
for i in all_links:
print(i)
if __name__ == '__main__':
main()
Traceback (most recent call last):
File "MAIN.py", line 32, in <module>
main()
File "MAIN.py", line 25, in main
all_links = get_all_links( get_html(url) )
File "MAIN.py", line 13, in get_all_links
span_s = spans.find_all('span', class_='line-event__name')
AttributeError: 'NoneType' object has no attribute 'find_all'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question