We help IT Professionals succeed at work.

Python AttributeError: 'list' object has no attribute 'find_all'

adbyits
adbyits used Ask the Experts™
on
Hi all i am new to the site i am trying to get a python script i am doing working and i am getting a error AttributeError: 'list' object has no attribute 'find_all'

I have attached the code , i would like to get all the different fulds in to different elements so i can save them to a mysql database

#erth Airpirt DEPARTURE IMPORT SCRIPT
#CREATED BY ADBY IT AND MEDIA SOLUTIONS
#VERSION 1.1
#DATE 25 NOVEMBER 2019
#UPDATED 26 NOVEMBER 2019
#AUTHOR ADAM R WOLARCZUK


from requests_html import HTMLSession # import HTMLSession from requests_html
import requests
from requests_html import HTMLSession
from bs4 import BeautifulSoup
import mysql.connector


session = HTMLSession() # create an HTML Session object
resp = session.get("https://www.adelaideairport.com.au/flight-information/flight-search/") # Use the object above to connect to needed webpage
resp.html.render() # Run JavaScript code on webpage


#page = requests.get("https://www.adelaideairport.com.au/flight-information/flight-search/")
soup = BeautifulSoup(resp.html.html, "lxml")
flights = resp.html.find("SearchResultFlightListTable")
flight_items = flights.find_all(class_="row")
flight = flight_items[0]
print(flight.prettify())
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
here "flights" is list type variable and the list does not have find_all function.
instead, you can use .index function to find the index of the element and from there you can access value.