Home > OS >  Scraping websites with find method
Scraping websites with find method

Time:10-21

I am trying to scrape information with bs4 after getting the results with my first find method which prints out all the correct information. After this I am trying to the loop and print all the names. But the find method is throwing the error "find() takes no keyword arguments". I have tried a few different methods, but none seem to be able to extract the name.

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from bs4 import BeautifulSoup
import requests
import pandas as pd

URL = "https://www.kudosprime.com/fh4/carlist.php?range=2000"
page = requests.get(URL)

soup = BeautifulSoup(page.content, "html.parser")

results = soup.find(id="carlist")

for r in results:
    print(r)

for r in results:
    name = r.find('a',attrs={'class':'name'})
    print(name.text)

CodePudding user response:

This is how I would do it.

from bs4 import BeautifulSoup
import requests
import pandas as pd

URL = "https://www.kudosprime.com/fh4/carlist.php?range=2000"
page = requests.get(URL)

soup = BeautifulSoup(page.content, "html.parser")
result = soup.find("div", {"id": "carlist"})

names = result.find_all('a',{'class':'name'})
name_list = [name.text for name in names]
print(name_list)
['2017 Abarth 124 SPIDER ▲', '2016 Abarth 695 BIPOSTO ▲', '1980 Abarth FIAT 131 ▲', '1968 Abarth 595 ESSEESSE ▲', '2017 Acura NSX ▲', '2002 Acura RSX TYPE-S ▲', '2001 Acura INTEGRA TYPE-R ▲', '2018 Alfa Romeo STELVIO QUADRIFOGLIO ▲', '2017 Alfa Romeo GIULIA QUADRIFOGLIO ▲', '2016 Alfa Romeo GIULIA QUADRIFOGLIO FORZA EDITION ▲', '2014 Alfa Romeo 4C ▲', '2007 Alfa Romeo 8C COMPETIZIONE ▲', '2007 Alfa Romeo 8C COMPETIZIONE FORZA EDITION ▲', '1992 Alfa Romeo 155 Q4 ▲', '1968 Alfa Romeo 33 STRADALE ▲', '1965 Alfa Romeo GIULIA SPRINT GTA STRADALE ▲', '1965 Alfa Romeo GIULIA TZ2 ▲', '1934 Alfa Romeo P3 ▲', '2017 Alpine A110 ▲', '2015 Alumi Craft CLASS 10 RACE CAR ▲', '2015 Alumi Craft CLASS 10 RACE CAR FORZA EDITION ▲', '1973 AMC GREMLIN X ▲', '1971 AMC JAVELIN AMX ▲', '1970 AMC REBEL "THE MACHINE" ▲', '2554 AMG TRANSPORT DYNAMICS M12S WARTHOG CST ▲', '2018 Apollo INTENSA EMOZIONE ▲', '2016 Ariel NOMAD ▲', '2013 Ariel ATOM 500 V8 ▲', '2012 Ascari KZ1R ▲', '2019 Aston Martin DBS SUPERLEGGERA ▲', '2018 Aston Martin Vantage ▲', '2017 Aston Martin DB11 ▲', '2017 Aston Martin DB11 PREORDER CAR ▲', '2017 Aston Martin VANQUISH ZAGATO COUPE ▲', '2017 Aston Martin VULCAN AMR PRO ▲', '2016 Aston Martin VANTAGE GT12 ▲', '2016 Aston Martin VULCAN ▲', '2016 Aston Martin VULCAN FORZA EDITION ▲', '2013 Aston Martin V12 VANTAGE S ▲', '2012 Aston Martin VANQUISH ▲', '2010 Aston Martin ONE-77 ▲', '1964 Aston Martin DB5 ▲', '1960 Aston Martin DB4 GT ZAGATO ▲', '1958 Aston Martin DBR1 ▲', '2018 ATS GT ▲', '2016 Audi R8 V10 PLUS ▲', '2015 Audi RS 6 AVANT ▲', '2015 Audi S1 ▲', '2015 Audi TTS COUPE ▲', '2013 Audi COUPE R8 V10 PLUS 5.2 FSI QUATTRO ▲', '2013 Audi RS 4 AVANT ▲', '2013 Audi RS 7 SPORTBACK ▲', '2011 Audi RS 3 SPORTBACK ▲', '2011 Audi RS 5 COUPE ▲', '2010 Audi TT RS COUPE ▲', '2009 Audi RS6 ▲', '2006 Audi RS 4 ▲', '2003 Audi RS 6 ▲', '2001 Audi RS 4 AVANT ▲', '1995 Audi RS 2 AVANT ▲', '1986 Audi #2 AUDI SPORT QUATTRO S1 ▲', '1983 Audi SPORT QUATTRO ▲', '1964 Austin FX4 TAXI ▲', '1924 Austin SEVEN ▲', '1965 Austin-Healey 3000 MKIII ▲', '1958 Austin-Healey SPRITE MKI ▲', '1939 Auto Union TYPE D ▲', '2014 BAC MONO ▲', '2017 Bentley CONTINENTAL SUPERSPORTS ▲', '2016 Bentley BENTAYGA ▲', '2013 Bentley CONTINENTAL GT SPEED ▲', '2013 Bentley CONTINENTAL GT SPEED FORZA EDITION ▲', '1991 Bentley TURBO R ▲', '1931 Bentley 4-1/2 LITER SUPERCHARGED ▲', '1931 Bentley 8-LITER ▲', '2019 BMW Z4 Roadster ▲', '2018 BMW i8 ROADSTER ▲', '2018 BMW M5 ▲', '2016 BMW M2 COUPE ▲', '2016 BMW M4 GTS ▲', '2015 BMW I8 ▲', '2015 BMW X6 M ▲', '2014 BMW M4 COUPE ▲', '2013 BMW M6 COUPE ▲', '2013 BMW M6 COUPE FORZA EDITION ▲', '2012 BMW M5 ▲', '2011 BMW 1 SERIES M COUPE ▲', '2011 BMW X5 M ▲', '2011 BMW Z4 SDRIVE35IS ▲', '2010 BMW M3 GTS ▲', '2009 BMW M5 ▲', '2008 BMW M3 ▲', '2008 BMW Z4 M COUPE ▲', '2005 BMW M3 ▲', '2003 BMW M5 ▲', '2002 BMW M3-GTR ▲', '2002 BMW Z3 M COUPE ▲', '1997 BMW M3 ▲', '1995 BMW 850CSI ▲', '1995 BMW M5 ▲', '1991 BMW M3 ▲', '1988 BMW M5 ▲', '1988 BMW M5 FORZA EDITION ▲', '1981 BMW M1 ▲', '1973 BMW 2002 TURBO ▲', '1957 BMW ISETTA 300 EXPORT ▲', '2012 Bowler EXR S ▲', '2019 Bugatti DIVO ▲', '2018 Bugatti CHIRON ▲', '2011 Bugatti VEYRON SUPER SPORT ▲', '1992 Bugatti EB110 SUPER SPORT ▲', '1926 Bugatti TYPE 35 C ▲', '1987 Buick REGAL GNX ▲', '1970 Buick GSX ▲', '2016 Cadillac ATS-V ▲', '2016 Cadillac CTS-V SEDAN ▲', '2013 Cadillac XTS LIMOUSINE ▲', '2012 Cadillac ESCALADE ESV ▲', '1959 Cadillac ELDORADO BIARRITZ CONVERTIBLE ▲', '2018 Can-Am MAVERICK X RS TURBO R ▲', '2013 Caterham SUPERLIGHT R500 ▲', '2013 Caterham SUPERLIGHT R500 FORZA EDITION ▲', '2020 Chevrolet C8 CORVETTE STINGRAY COUPE ▲', '2019 Chevrolet Corvette ZR1 ▲', '2018 Chevrolet CAMARO ZL1 1LE ▲', '2018 Chevrolet Silverado 1500 DeBerti Design ▲', '2017 Chevrolet CAMARO ZL1 ▲', '2017 Chevrolet CAMARO ZL1 PREORDER CAR ▲', '2017 Chevrolet COLORADO ZR2 ▲', '2015 Chevrolet CAMARO Z/28 ▲', '2015 Chevrolet CORVETTE Z06 ▲', '2009 Chevrolet CORVETTE ZR1 ▲', '2002 Chevrolet CORVETTE Z06 ▲', '1996 Chevrolet Impala SS ▲', '1995 Chevrolet CORVETTE ZR-1 ▲', '1990 Chevrolet CAMARO IROC-Z ▲', '1988 Chevrolet MONTE CARLO SUPER SPORT ▲', '1979 Chevrolet CAMARO Z28 ▲', '1970 Chevrolet CAMARO Z28 ▲', '1970 Chevrolet CHEVELLE SUPER SPORT 454 ▲', '1970 Chevrolet Chevelle Super Sport Barrett-Jackson Edition ▲', '1970 Chevrolet CORVETTE ZR-1 ▲', '1970 Chevrolet EL CAMINO SUPER SPORT 454 ▲', '1969 Chevrolet CAMARO SUPER SPORT COUPE ▲', '1969 Chevrolet NOVA SUPER SPORT 396 ▲', '1969 Chevrolet NOVA SUPER SPORT 396 FORZA EDITION ▲', '1967 Chevrolet CHEVELLE SUPER SPORT 396 ▲', '1967 Chevrolet CORVETTE STINGRAY 427 ▲', '1966 Chevrolet NOVA SUPER SPORT ▲', '1964 Chevrolet IMPALA SUPER SPORT 409 ▲', '1960 Chevrolet CORVETTE ▲', '1957 Chevrolet BEL AIR ▲', '1955 Chevrolet 150 UTILITY SEDAN ▲', '1953 Chevrolet CORVETTE ▲', '1972 Chrysler VH VALIANT CHARGER R/T E49 ▲', '1975 Citroën DS 23', '1970 Datsun 510 ▲', '2018 Dodge CHALLENGER SRT DEMON ▲', '2018 Dodge DURANGO SRT ▲', '2016 Dodge VIPER ACR ▲', '2015 Dodge CHALLENGER SRT HELLCAT ▲', '2015 Dodge CHARGER SRT HELLCAT ▲', '2013 Dodge SRT VIPER GTS ▲', '2008 Dodge VIPER SRT10 ACR ▲', '1999 Dodge VIPER GTS ACR ▲', '1970 Dodge CHALLENGER R/T ▲', '1969 Dodge CHARGER DAYTONA HEMI ▲', '1969 Dodge CHARGER R/T ▲', '1968 Dodge DART HEMI SUPER STOCK ▲', '2013 Donkervoort D8 GTO ▲', '2011 DS Automobiles DS 3 RACING ▲', '2012 Eagle SPEEDSTER ▲', '2018 Exomotive Exocet Off-Road ▲', '2019 Ferrari 488 PISTA ▲', '2018 Ferrari PORTOFINO ▲', '2017 Ferrari 812 SUPERFAST ▲', '2017 Ferrari GTC4Lusso ▲', '2015 Ferrari 488 GTB ▲', '2015 Ferrari F12TDF ▲', '2014 Ferrari CALIFORNIA T ▲', '2014 Ferrari FXX K ▲', '2013 Ferrari 458 SPECIALE ▲', '2013 Ferrari LAFERRARI ▲', '2012 Ferrari 599XX EVOLUTION ▲', '2012 Ferrari F12BERLINETTA ▲', '2011 Ferrari FF ▲', '2010 Ferrari 599 GTO ▲', '2010 Ferrari 599XX ▲', '2009 Ferrari 458 ITALIA ▲', '2007 Ferrari 430 SCUDERIA ▲', '2005 Ferrari FXX ▲', '2003 Ferrari 360 CHALLENGE STRADALE ▲', '2002 Ferrari 575M MARANELLO ▲', '2002 Ferrari ENZO FERRARI ▲', '1996 Ferrari F50 GT ▲', '1996 Ferrari Welcome Pack F50 GT ▲', '1995 Ferrari F50 ▲', '1994 Ferrari F355 BERLINETTA ▲', '1992 Ferrari 512 TR ▲', '1989 Ferrari F40 COMPETIZIONE ▲', '1987 Ferrari F40 ▲', '1984 Ferrari 288 GTO ▲', '1970 Ferrari 512 S ▲', '1969 Ferrari DINO 246 GT ▲', '1968 Ferrari 365 GTB/4 ▲', '1967 Ferrari #24 FERRARI SPA 330 P4 ▲', '1963 Ferrari 250LM ▲', '1962 Ferrari 250 GT BERLINETTA LUSSO ▲', '1962 Ferrari 250 GTO ▲', '1957 Ferrari 250 CALIFORNIA ▲', '1957 Ferrari 250 TESTA ROSSA ▲', '1953 Ferrari 500 MONDIAL ▲', '1948 Ferrari 166MM BARCHETTA ▲', '1980 Fiat 124 SPORT SPIDER ▲', '1975 Fiat X1/9 ▲', '1969 Fiat DINO 2.4 COUPE ▲', '2020 Ford MUSTANG SHELBY GT500 ▲', '2019 Ford Ranger Raptor ▲', '2018 Ford #25 MUSTANG RTR ▲', '2018 Ford #88 MUSTANG RTR ▲', '2018 Ford F-150 PRERUNNER DEBERTI DESIGN TRUCK ▲', '2018 Ford MUSTANG GT ▲', '2018 Ford MUSTANG GT DEBERTI DESIGN ▲', '2018 Ford MUSTANG RTR SPEC 5 ▲', '2017 Ford #14 RAHAL LETTERMAN LANIGAN RACING GRC FIESTA ▲', '2017 Ford F-150 RAPTOR ▲', '2017 Ford FOCUS RS ▲', '2017 Ford FOCUS RS PREORDER CAR ▲', '2017 Ford GT ▲', '2017 Ford M-SPORT FIESTA RS ▲', '2017 Ford Welcome Pack GT ▲', '2016 Ford SHELBY GT350R ▲', '2015 Ford FALCON GT F 351 ▲', '2014 Ford #11 ROCKSTAR F-150 TROPHY TRUCK ▲', '2014 Ford FIESTA ST ▲', '2014 Ford FPV LIMITED EDITION PURSUIT UTE ▲', '2014 Ford RANGER T6 RALLY RAID ▲', '2013 Ford SHELBY GT500 ▲', '2011 Ford F-150 SVT RAPTOR ▲', '2011 Ford TRANSIT SUPERSPORTVAN ▲', '2011 Ford TRANSIT SUPERSPORTVAN FORZA EDITION ▲', '2010 Ford CROWN VICTORIA POLICE INTERCEPTOR ▲', '2009 Ford FOCUS RS ▲', '2005 Ford GT ▲', '2003 Ford FOCUS RS ▲', '2000 Ford SVT COBRA R ▲', '1999 Ford RACING PUMA ▲', '1994 Ford SUPERVAN 3 ▲', '1993 Ford SVT COBRA R ▲', '1992 Ford ESCORT RS COSWORTH ▲', '1987 Ford SIERRA COSWORTH RS500 ▲', '1986 Ford ESCORT RS TURBO ▲', '1985 Ford RS200 EVOLUTION ▲', '1981 Ford FIESTA XR2 ▲', '1977 Ford #5 ESCORT RS1800 MK II ▲', '1977 Ford ESCORT RS1800 ▲', '1975 Ford BRONCO ▲', '1975 Ford Bronco Barrett-Jackson Edition ▲', '1973 Ford CAPRI RS3100 ▲', '1973 Ford CAPRI RS3100 FORZA EDITION ▲', '1973 Ford ESCORT RS1600 ▲', '1973 Ford XB FALCON GT ▲', '1972 Ford FALCON XA GT-HO ▲', '1972 Ford FALCON XA GT-HO FORZA EDITION ▲', '1971 Ford MUSTANG MACH 1 ▲', '1970 Ford GT70 ▲', '1969 Ford MUSTANG BOSS 302 ▲', '1968 Ford Mustang GT 2 2 Fastback ▲', '1966 Ford #2 GT40 MKII LE MANS ▲', '1966 Ford LOTUS CORTINA ▲', '1965 Ford MUSTANG GT COUPE ▲', '1965 Ford Transit ▲', '1964 Ford GT40 MKI ▲', '1959 Ford ANGLIA 105E ▲', '1956 Ford F-100 ▲', '1946 Ford SUPER DELUXE STATION WAGON ▲', '1940 Ford DE LUXE COUPE ▲', '1932 Ford Custom Double Down ▲', '1932 Ford DE LUXE FIVE-WINDOW COUPE ▲', '1932 Ford Roadster Hula Girl ▲', '2018 Formula Drift #64 NISSAN 370Z ▲', '2016 Formula Drift #530 HSV MALOO GEN-F ▲', '2015 Formula Drift #13 FORD MUSTANG ▲', '2013 Formula Drift #777 CHEVROLET CORVETTE ▲', '2007 Formula Drift #117 599 GTB FIORANO ▲', '2006 Formula Drift #43 DODGE VIPER SRT10 ▲', '1997 Formula Drift #777 NISSAN 240SX ▲', '1996 Formula Drift #232 NISSAN 240SX ▲', '1995 Formula Drift #118 NISSAN 240SX ▲', '1989 Formula Drift #98 BMW 325i ▲', '2018 Funco Motorsports F9 ▲', '1992 GMC TYPHOON ▲', '1991 GMC SYCLONE ▲', '1983 GMC VANDURA G-1500 ▲', '1985 HDT VK COMMODORE GROUP A ▲', '2019 Hennessey VELOCIRAPTOR 6X6 ▲', '2012 Hennessey VENOM GT ▲', '1966 Hillman IMP ▲', '1988 Holden VL COMMODORE GROUPE A SV ▲', '1977 Holden TORANA A9X ▲', '1974 Holden SANDMAN HQ PANEL VAN ▲', '1973 Holden HQ MONARO GTS 350 ▲', '2018 Honda CIVIC TYPE R ▲', '2016 Honda CIVIC COUPE GRC ▲', '2015 Honda CIVIC TYPE R ▲', '2015 Honda RIDGELINE BAJA TROPHY TROPHY TRUCK ▲', '2009 Honda S2000 CR ▲', '2007 Honda CIVIC TYPE-R ▲', '2005 Honda NSX-R ▲', '2005 Honda NSX-R GT', '2004 Honda CIVIC TYPE-R ▲', '2003 Honda S2000 ▲', '1997 Honda CIVIC TYPE R ▲', '1994 Honda Prelude ▲', '1992 Honda NSX-R ▲', '1991 Honda CR-X SIR ▲', '1984 Honda CIVIC CRX MUGEN ▲', '1974 Honda Civic RS ▲', '1970 Honda S800 ▲', '2017 Hoonigan GYMKHANA 10 FORD FIESTA ST ▲', '2016 Hoonigan GYMKHANA 10 FORD FOCUS RS RX ▲', '2016 Hoonigan GYMKHANA 9 FORD FOCUS RS RX ▲', '2016 Hoonigan Welcome Pack GYMKHANA 9 FORD FOCUS RS RX ▲', '2015 Hoonigan GYMKHANA 8 Ford Fiesta ST RX43 ▲', '1992 Hoonigan MAZDA RX-7 TWERKSTALLION ▲', '1991 Hoonigan GYMKHANA 10 FORD ESCORT COSWORTH GROUP A ▲', '1991 Hoonigan RAUH-WELT BEGRIFF PORSCHE 911 TURBO ▲', '1986 Hoonigan FORD RS200 EVOLUTION ▲', '1978 Hoonigan FORD ESCORT RS1800 ▲', '1977 Hoonigan GYMKHANA 10 FORD F-150 “HOONITRUCK” ▲', '1974 Hoonigan BRONCO ▲', '1972 Hoonigan CHEVROLET NAPALM NOVA ▲', '1965 Hoonigan FORD “HOONICORN” MUSTANG ▲', '1965 Hoonigan GYMKHANA 10 FORD HOONICORN MUSTANG ▲', '1955 Hoonigan CHEVROLET BEL AIR ▲', '2018 Hot Wheels 2JETZ', '2012 Hot Wheels RIP ROD ▲', '2011 Hot Wheels Bone Shaker ▲', '2005 Hot Wheels Ford Mustang ▲', '1972 Hot Wheels CHEVROLET LUV', '1969 Hot Wheels INTERNATIONAL-HARVESTER LOADSTAR CO-1600', '1969 Hot Wheels TWIN MILL ▲', '1957 Hot Wheels NASH METROPOLITAN CUSTOM', "1957 Hot Wheels STUDEBAKER GOLDEN 'DREAM ROADSTER'", '1949 Hot Wheels FORD F-5 DUALLY CUSTOM HOT ROD', '2014 HSV GEN-F GTS ▲', '2014 HSV LIMITED EDITION GEN-F GTS MALOO ▲', '2011 HSV GTS ▲', '1996 HSV GTSR ▲', '1952 Hudson HORNET ▲', '2006 HUMMER H1 ALPHA ▲', '2006 HUMMER H1 ALPHA OPEN TOP ▲', '2019 Hyundai VELOSTER N ▲', '2015 Infiniti Q60 CONCEPT ▲', '2014 Infiniti Q50 EAU ROUGE ▲', '1970 International SCOUT 800A ▲', '2018 ItalDesign ZEROUNO ▲', '2018 Jaguar I-PACE ▲', '2017 Jaguar F-PACE S ▲', '2016 Jaguar F-TYPE PROJECT 7 ▲', '2015 Jaguar F-TYPE R COUPE ▲', '2015 Jaguar XE-S ▲', '2015 Jaguar XFR-S ▲', '2015 Jaguar XKR-S GT ▲', '2012 Jaguar XKR-S ▲', '1993 Jaguar XJ220 ▲', '1990 Jaguar XJ-S ▲', '1964 Jaguar LIGHTWEIGHT E-TYPE ▲', '1961 Jaguar E-TYPE S1 ▲', '1959 Jaguar MK II 3.8 ▲', '1956 Jaguar D-TYPE ▲', '1954 Jaguar XK120 SE ▲', '1953 Jaguar C-Type ▲', '2015 James Bond Edition ASTON MARTIN DB10 ▲', '2010 James Bond Edition JAGUAR C-X75 ▲', '2008 James Bond Edition ASTON MARTIN DBS ▲', '1999 James Bond Edition BMW Z8 ▲', '1987 James Bond Edition ASTON MARTIN V8 ▲', '1981 James Bond Edition CITROEN 2CV6 ▲', '1977 James Bond Edition LOTUS ESPRIT S1 ▲', '1974 James Bond Edition AMC HORNET X HATCHBACK ▲', '1969 James Bond Edition ASTON MARTIN DBS ▲', '1964 James Bond Edition ASTON MARTIN DB5 ▲', '2020 Jeep GLADIATOR RUBICON', '2018 Jeep GRAND CHEROKEE TRACK HAWK ▲', '2016 Jeep TRAILCAT ▲', '2014 Jeep GRAND CHEROKEE SRT ▲', '2013 Jeep Wrangler Unlimited Deberti Design ▲', '2012 Jeep WRANGLER RUBICON ▲', '1976 Jeep CJ5 RENEGADE ▲', '1976 Jeep Welcome Pack CJ5 RENEGADE ▲', '2018 Kia STINGER ▲', '2020 Koenigsegg JESKO ▲', '2017 Koenigsegg AGERA RS ▲', '2016 Koenigsegg REGERA ▲', '2015 Koenigsegg ONE:1 ▲', '2011 Koenigsegg AGERA ▲', '2008 Koenigsegg CCGT ▲', '2006 Koenigsegg CCX ▲', '2002 Koenigsegg CC8S ▲', '2018 KTM X-BOW GT4 ▲', '2013 KTM X-BOW R ▲', '2019 Lamborghini Urus ▲', '2018 Lamborghini HURACAN PERFORMANTE ▲', '2016 Lamborghini AVENTADOR LP750-4 SV ▲', '2016 Lamborghini CENTENARIO LP 770-4 ▲', '2014 Lamborghini HURACAN LP 610-4 ▲', '2014 Lamborghini URUS CONCEPT ▲', '2013 Lamborghini VENENO ▲', '2012 Lamborghini Aventador J ▲', '2012 Lamborghini AVENTADOR LP700-4 ▲', '2012 Lamborghini AVENTADOR LP700-4 FORZA EDITION ▲', '2012 Lamborghini GALLARDO LP570-4 SPYDER PERFORMANTE ▲', '2012 Lamborghini Welcome Pack AVENTADOR LP700-4 ▲', '2011 Lamborghini GALLARDO LP 570-4 SUPERLEGGERA ▲', '2011 Lamborghini SESTO ELEMENTO ▲', '2010 Lamborghini MURCIELAGO LP 670-4 SV ▲', '2008 Lamborghini Reventon ▲', '2008 Lamborghini REVENTON FORZA EDITION ▲', '1999 Lamborghini DIABLO GTR ▲', '1997 Lamborghini DIABLO SV ▲', '1988 Lamborghini COUNTACH LP5000 QV ▲', '1986 Lamborghini LM 002 ▲', '1972 Lamborghini Jarama S ▲', '1967 Lamborghini MIURA P400 ▲', '1992 Lancia DELTA HF INTEGRALE EVO ▲', '1986 Lancia DELTA S4 ▲', '1982 Lancia 037 STRADALE ▲', '1974 Lancia STRATOS HF STRADALE ▲', '1968 Lancia FULVIA COUPE RALLYE 1.6 HF ▲', '2018 Land Rover RANGE ROVER VELAR FIRST EDITION ▲', '2015 Land Rover RANGE ROVER SPORT SVR ▲', '1997 Land Rover DEFENDER 90 ▲', '1973 Land Rover RANGE ROVER ▲', '1972 Land Rover SERIES III ▲', '1972 Land Rover SERIES III FORZA EDITION ▲', '2019 Lego Speed Champions BUGATTI CHIRON ▲', '2019 Lego Speed Champions MCLAREN SENNA ▲', '1987 Lego Speed Champions FERRARI F40 COMPETIZION ▲', '1974 Lego Speed Champions PORSCHE 911 TURBO 3.0 ▲', '1967 Lego Speed Champions MINI COOPER S RALLY ▲', '2015 Lexus RC F ▲', '2010 Lexus LFA ▲', '2009 Lexus IS F', '2014 Local Motors RALLY FIGHTER ▲', '1969 Lola #6 PENSKE SUNOCO T70 MKIIIB ▲', '2016 Lotus 3-ELEVEN ▲', '2012 Lotus EXIGE S ▲', '2011 Lotus EVORA S ▲', '2009 Lotus 2-ELEVEN ▲', '2005 Lotus ELISE 111S ▲', '2002 Lotus ESPRIT V8 ▲', '2000 Lotus 340R ▲', '1999 Lotus ELISE SERIES 1 SPORT 190 ▲', '1997 Lotus ELISE GT1 ▲', '1971 Lotus ELAN SPRINT ▲', '1956 Lotus ELEVEN ▲', '2017 Maserati Levante S ▲', '2014 Maserati GHIBLI S Q4 ▲', '2010 Maserati GRAN TURISMO S ▲', '2008 Maserati VERSIONE CORSA ▲', '2004 Maserati MC12 ▲', '2004 Maserati MC12 FORZA EDITION ▲', '1961 Maserati TIPO 61 BIRDCAGE ▲', '1957 Maserati 300 S ▲', '1953 Maserati A6GCS/53 PININFARINA BERLINETTA ▲', '1939 Maserati 8CTF ▲', '2016 Mazda MX-5 ▲', '2013 Mazda MX-5 ▲', '2011 Mazda RX-8 R3 ▲', '2005 Mazda MAZDASPEED MX-5 ▲', '2002 Mazda RX-7 SPIRIT R TYPE-A ▲', '1997 Mazda RX-7 ▲', '1994 Mazda MX-5 MIATA ▲', '1990 Mazda SAVANNA RX-7 ▲', '1985 Mazda RX-7 GSL-SE ▲', '1973 Mazda RX-3', '1972 Mazda COSMO 110S SERIES II ▲', '2019 McLaren 720S SPIDER ▲', '2019 McLaren SPEEDTAIL ▲', '2018 McLaren 600LT COUPE ▲', '2018 McLaren 720S COUPE ▲', '2018 McLaren 720S COUPE PREORDER CAR ▲', '2018 McLaren SENNA ▲', '2015 McLaren 570S COUPE ▲', '2015 McLaren 650S COUPE ▲', '2014 McLaren 650S Spider ▲', '2013 McLaren P1 ▲', '2011 McLaren 12C COUPE ▲', '1997 McLaren F1 GT ▲', '1993 McLaren F1 ▲', '2018 Mercedes-AMG E 63 S ▲', '2018 Mercedes-AMG GT 4-DOOR COUPE ▲', '2017 Mercedes-AMG GT R PREORDER CAR ▲', '2017 Mercedes-AMG GTR ▲', '2016 Mercedes-AMG C 63 S COUPE ▲', '2015 Mercedes-AMG GT S ▲', '2018 Mercedes-Benz X-CLASS ▲', '2017 Mercedes-Benz E 350 D 4Matic All-Terrain Project E-AT ▲', '2015 Mercedes-Benz #24 TANKPOOL24 RACING TRUCK ▲', '2014 Mercedes-Benz G 63 AMG 6×6 ▲', '2014 Mercedes-Benz UNIMOG U5023 ▲', '2013 Mercedes-Benz A 45 AMG ▲', '2013 Mercedes-Benz E 63 AMG ▲', '2013 Mercedes-Benz G 65 AMG ▲', '2012 Mercedes-Benz 63 AMG COUPE BLACK SERIES ▲', '2012 Mercedes-Benz SLK 55 AMG ▲', '2011 Mercedes-Benz SLS AMG ▲', '2009 Mercedes-Benz 65 AMG BLACK SERIES ▲', '2009 Mercedes-Benz SL 65 AMG BLACK SERIES FORZA EDITION ▲', '1998 Mercedes-Benz AMG CLK GTR ▲', '1990 Mercedes-Benz 190E 2.5-16 EVOLUTION II ▲', '1987 Mercedes-Benz AMG HAMMER COUPE ▲', '1967 Mercedes-Benz 280 SL ▲', '1955 Mercedes-Benz 300 SLR ▲', '1954 Mercedes-Benz 300 SL COUPE ▲', '1939 Mercedes-Benz W154 ▲', '1929 Mercedes-Benz SUPER SPORT KURZ BARKER ROADSTER ▲', '1970 Mercury COUGAR ELIMINATOR ▲', '1949 Mercury COUPE ▲', '1971 Meyers MANX ▲', '1986 MG METRO 6R4 ▲', '1966 MG MGB GT ▲', '1958 MG MGA TWIN-CAM ▲', '1938 MG TA Midget ▲', '2018 Mini JOHN COOPER WORKS CONVERTIBLE ▲', '2018 Mini JOHN COOPER WORKS COUNTRYMAN ALL4 ▲', '2018 Mini X-RAID JOHN COOPER WORKS BUGGY ▲', '2013 Mini X-RAID ALL4 RACING COUNTRYMAN ▲', '2012 Mini JOHN COOPER WORKS GP ▲', '2009 Mini JOHN COOPER WORKS ▲', '1965 Mini COOPER S ▲', '2008 Mitsubishi Lancer Evo X GSR ▲', '2006 Mitsubishi Lancer Evo IX MR ▲', '2004 Mitsubishi Lancer Evo VIII MR ▲', '1999 Mitsubishi Lancer Evo VI GSR ▲', '1997 Mitsubishi GTO ▲', '1995 Mitsubishi Eclipse GSX ▲', '1992 Mitsubishi Galant VR4 ▲', '1988 Mitsubishi STARION ESI-R ▲', '2018 Morgan Aero GT ▲', '2014 Morgan 3 WHEELER ▲', '2010 Morgan AERO SUPERSPORTS ▲', '1965 Morris MINI-TRAVELLER ▲', '1958 Morris MINOR 1000 ▲', '1953 Morris Minor Series II Traveler ▲', '2010 Mosler MT900S ▲', '1933 Napier NAPIER-RAILTON', '2018 Nissan SENTRA NISMO ▲', '2017 Nissan GT-R ▲', '2017 Nissan GT-R PREORDER CAR ▲', '2016 Nissan TITAN WARRIOR CONCEPT ▲', '2016 Nissan TITAN WARRIOR CONCEPT FORZA EDITION ▲', '2012 Nissan GT-R BLACK EDITION ▲', '2010 Nissan 370Z ▲', '2003 Nissan FAIRLADY Z ▲', '2002 Nissan SKYLINE GT-R V-SPEC II ▲', '2000 Nissan SILVIA SPEC-R ▲', '1998 Nissan R390 ▲', '1998 Nissan SILVIA K’S AERO ▲', '1997 Nissan SKYLINE GT-R V-SPEC ▲', '1995 Nissan NISMO GT-R LM ▲', '1995 Nissan NISMO GT-R LM FORZA EDITION ▲', '1994 Nissan FAIRLADY Z VERSION S TWIN TURBO ▲', '1994 Nissan SILVIA K’S ▲', '1993 Nissan 240SX SE ▲', '1993 Nissan SKYLINE GT-R V-SPEC ▲', '1992 Nissan SILVIA CLUB K’S ▲', '1990 Nissan PULSAR GTI-R ▲', '1987 Nissan SKYLINE GTS-R (R31) ▲', '1973 Nissan SKYLINE H/T 2000GT-R ▲', '1971 Nissan SKYLINE 2000GT-R ▲', '1969 Nissan FAIRLADY Z 432 ▲', '2010 Noble M600 ▲', '1969 Oldsmobile HURST/OLDS 442 ▲', '1984 Opel MANTA 400 ▲', '1963 Opel Kadett A ▲', '2016 Pagani HUAYRA BC ▲', '2012 Pagani HUAYRA ▲', '2010 Pagani ZONDA R ▲', '2010 Pagani ZONDA R FORZA EDITION ▲', '2009 Pagani ZONDA CINQUE ROADSTER ▲', '1965 Peel Trident ▲', '1962 Peel P50 ▲', '2011 Penhall THE CHOLLA ▲', '2007 Peugeot 207 SUPER 2000 ▲', '1991 Peugeot 205 RALLYE ▲', '1984 Peugeot 205 T16 ▲', '1984 Peugeot 205 TURBO 16 FORZA EDITION ▲', '1971 Plymouth CUDA 426 HEMI ▲', '1970 Plymouth Hemi Cuda Convertible Barrett-Jackson Edition ▲', '1959 Plymouth Atomic Punk Bubbletop ▲', '1958 Plymouth FURY ▲', '2015 Polaris RZR XP1000 EPS ▲', '1987 Pontiac FIREBIRD TRANS AM GTA ▲', '1977 Pontiac FIREBIRD TRANS AM ▲', '1973 Pontiac FIREBIRD TRANS AM SD-455 ▲', '1969 Pontiac GTO JUDGE ▲', '1968 Pontiac FIREBIRD ▲', '1965 Pontiac GTO ▲', '2019 Porsche 911 Carrera S ▲', '2019 Porsche 911 GT3 RS ▲', '2019 Porsche MACAN TURBO ▲', '2018 Porsche 718 CAYMAN GTS ▲', '2018 Porsche 911 GT2 RS ▲', '2018 Porsche CAYENNE TURBO ▲', '2017 Porsche PANAMERA TURBO ▲', '2016 Porsche 911 GT3 RS ▲', '2016 Porsche 911 GT3 RS PREORDER CAR ▲', '2016 Porsche CAYMAN GT4 ▲', '2015 Porsche CAYMAN GTS ▲', '2015 Porsche MACAN TURBO ▲', '2014 Porsche 911 TURBO S ▲', '2014 Porsche 918 SPYDER ▲', '2012 Porsche 911 GT2 RS ▲', '2012 Porsche 911 GT3 RS 4.0 ▲', '2012 Porsche CAYENNE TURBO ▲', '2004 Porsche 911 GT3 ▲', '2003 Porsche CARRERA GT ▲', '1998 Porsche 911 GT1 STRASSENVERSION ▲', '1995 Porsche 911 CARRERA 2 BY GUNTHER WERKS ▲', '1995 Porsche 911 GT2 ▲', '1993 Porsche 928 GTS', '1993 Porsche 968 Turbo S ▲', '1990 Porsche 911 REIMAGINED BY SINGER ▲', '1989 Porsche 944 TURBO ▲', '1987 Porsche 959 ▲', '1985 Porsche #186 959 PRODRIVE RALLY RAID5 ▲', '1982 Porsche 911 TURBO 3.3 ▲', '1973 Porsche 911 CARRERA RS ▲', '1971 Porsche #23 917/20 ▲', '1970 Porsche #3 917 LH ▲', '1970 Porsche 914/6 ▲', '1966 Porsche 906 CARRERA 6 ▲', '1964 Porsche 356 C CABRIOLET EMORY SPECIAL ▲', '1960 Porsche 356 RSR FROM EMORY MOTORSPORT', '1960 Porsche 718 RS 60 ▲', '1960 Porsche Welcome Pack 718 RS 60 ▲', '1959 Porsche 356 A1600 SUPER ▲', '1957 Porsche 356A SPEEDSTER ▲', '1955 Porsche 550A SPYDER ▲', '1951 Porsche #46 356 SL GMÜND COUPE ▲', '2058 Quadra TURBO-R V-TECH ▲', '723 Quartz REGALIA ▲', '723 Quartz REGALIA TYPE-D ▲', '2015 Radical RXC TURBO ▲', '2019 RAESR TACHYON SPEED ▲', '2017 RAM 1500 Rebel TRX Concept ▲', '2017 RAM 2500 POWER WAGON ▲', '1972 Reliant SUPERVAN III ▲', '2018 Renault MEGANE R.S. ▲', '2016 Renault CLIO R.S. 16 CONCEPT ▲', '2013 Renault CLIO R.S. 200 EDC ▲', '2010 Renault CLIO R.S. ▲', '2010 Renault CLIO R.S. FORZA EDITION ▲', '2010 Renault MEGANE R.S. 250 ▲', '2008 Renault MEGANE R26.R ▲', '2007 Renault CLIO RS 197 ▲', '2003 Renault SPORT CLIO V6 ▲', '1993 Renault CLIO WILLIAMS ▲', '1980 Renault 5 TURBO ▲', '1980 Renault 5 TURBO FORZA EDITION ▲', '1973 Renault ALPINE A110 1600S ▲', '2019 Rimac CONCEPT TWO ▲', '2016 RJ Anderson #37 POLARIS RZR-ROCKSTAR ENERGY ▲', '2010 Rossion Q1 ▲', '1984 Rover SD1 Vitesse ▲', '2018 Saleen S1', '2010 Saleen S5S Raptor ▲', '2004 Saleen S7 ▲', '2012 Shelby 1000 ▲', '1965 Shelby COBRA 427 S/C ▲', '1965 Shelby COBRA DAYTONA COUPE ▲', '1963 Shelby Monaco King Cobra ▲', '2016 Spania GTA GTA SPANO ▲', '2016 Subaru  Welcome Pack  #199 WRX STI VT15R RALLY CAR ▲', '2016 Subaru #199 WRX STI VT15R RALLY CAR ▲', '2015 Subaru WRX STI ▲', '2013 Subaru BRZ ▲', '2011 Subaru WRX STI ▲', '2008 Subaru IMPREZA WRX STI ▲', '2005 Subaru IMPREZA WRX STI ▲', '2004 Subaru IMPREZA WRX STI ▲', '1998 Subaru IMPREZA 22B STI ▲', '1990 Subaru LEGACY RS ▲', '1967 Sunbeam TIGER ▲', '1979 Talbot SUNBEAM LOTUS ▲', '2017 TAMO RACEMO ▲', '2014 Terradyne GURKHA LAPV ▲', '2018 Top Gear TRACK-TOR ▲', '2016 Toyota LAND CRUISER ARCTIC TRUCKS AT37 ▲', '2013 Toyota GT86 ▲', '2007 Toyota HILUX ARCTIC TRUCKS AT38 ▲', '1998 Toyota SUPRA RZ ▲', '1995 Toyota MR2 GT ▲', '1994 Toyota CELICA GT-FOUR ST205 ▲', '1993 Toyota #1 T100 BAJA TRUCK ▲', '1993 Toyota Welcome Pack #1 T100 BAJA TRUCK ▲', '1992 Toyota CELICA GT-FOUR RC ST185 ▲', '1992 Toyota SUPRA 2.0 GT TWIN TURBO ▲', '1989 Toyota MR2 SC ▲', '1985 Toyota SPRINTER TRUENO GT APEX ▲', '1974 Toyota CELICA GT ▲', '1974 Toyota COROLLA SR5 ▲', '1969 Toyota 2000 GT', '1979 Triumph TR7 ROADSTER ▲', '1970 Triumph TR6 PI ▲', '1962 Triumph SPITFIRE ▲', '1962 Triumph TR3B ▲', '2018 TVR GRIFFITH ▲', '2005 TVR SAGARIS ▲', '2005 TVR SAGARIS FORZA EDITION ▲', '2001 TVR TUSCAN S ▲', '1998 TVR CERBERA SPEED 12 ▲', '2015 Ultima EVOLUTION COUPE 1020 ▲', '2016 Vauxhall CORSA VXR ▲', '2012 Vauxhall ASTRA VXR ▲', '2010 Vauxhall INSIGNIA VXR ▲', '2009 Vauxhall CORSA VXR ▲', '2005 Vauxhall MONARO VXR ▲', '2004 Vauxhall VX220 TURBO ▲', '1990 Vauxhall LOTUS CARLTON ▲', '2018 Volkswagen #94 VOLKSWAGEN MOTORSPORT I.D R PIKES PEAK ▲', '2017 Volkswagen #34 VOLKSWAGEN ANDRETTI RALLYCROSS BEETLE ▲', '2014 Volkswagen GLOBAL RALLYCROSS BEETLE ▲', '2014 Volkswagen GOLF R ▲', '2011 Volkswagen SCIROCCO R ▲', '2010 Volkswagen GOLF R ▲', '2008 Volkswagen TOUAREG R50 ▲', '2003 Volkswagen GOLF R32 ▲', '1998 Volkswagen GTI VR6 MK3 ▲', '1995 Volkswagen CORRADO VR6 ▲', '1992 Volkswagen GOLF GTI16V MK2 ▲', '1983 Volkswagen GOLF GTI ▲', '1981 Volkswagen SCIROCCO S ▲', '1970 Volkswagen #1107 DESERT DINGO RACING STOCKBUG ▲', '1969 Volkswagen CLASS 5/1600 BAJA BUG ▲', '1967 Volkswagen KARMANN GHIA ▲', '1967 Volkswagen TYPE 3 1600 L ▲', '1966 Volkswagen DOUBLE CAB PICK-UP ▲', '1963 Volkswagen BEETLE ▲', '1963 Volkswagen TYPE 2 DE LUXE ▲', '1963 Volkswagen TYPE 2 DE LUXE FORZA EDITION ▲', '2016 Volvo IRON KNIGHT ▲', '2015 Volvo V60 POLESTAR ▲', '1997 Volvo 850 R ▲', '1983 Volvo 242 TURBO EVOLUTION ▲', '2017 VUHL 05RR ▲', '2016 W Motors LYKAN HYPERSPORT ▲', '1945 WILLYS MB JEEP ▲', '2019 Zenvo TSR-S ▲', '2016 Zenvo ST1 ▲']

From your name_list you are free to iterate over it if needed or index into it, but the names variable will also contain a list of each of the elements matching a

Note that find_all was what you needed rather than find. find_all returns a list of matches, find returns just the first match which you cannot iterate over.

CodePudding user response:

Your results is a single Tag object. Iterating over it, returns all it's children including text nodes.

From the documentation:

NavigableString supports most of the features described in Navigating the tree and Searching the tree, but not all of them. In particular, since a string can’t contain anything (the way a tag may contain a string or another tag), strings don’t support the .contents or .string attributes, or the find() method.

NavigableString class inherits from the unicode class, so calling find on a text node just calls the string's find method, which as the error says, takes no keyword arguments.

You probably only want nodes of cars, so you should call:

results = soup.find(id="carlist").find_all(class_="car")
  • Related