AndyReifman
AndyReifman

Reputation: 1834

Beautifulsoup find_All command not working

I've got some html where a bit of it looks like

<div class="large-12 columns">
 <div class="box">
  <div class="header">
   <h2>
    Line-Ups
   </h2>
  </div>
  <div class="large-6 columns aufstellung-box" style="padding: 0px;">
   <div class="unterueberschrift aufstellung-unterueberschrift-mannschaft">
    <div>
     <a class="vereinprofil_tooltip" href="/fc-portsmouth/startseite/verein/1020/saison_id/2006" id="1020">
      <img alt="Portsmouth FC" class="" src="https://tmssl.akamaized.net/images/wappen/verysmall/1020_1564722280.png?lm=1564722280" title=" "/>
...........
 <div class="large-6 columns" style="padding: 0px;">
   <div class="unterueberschrift aufstellung-unterueberschrift-mannschaft aufstellung-bordertop-small">
    <div>
     <a class="vereinprofil_tooltip" href="/fc-arsenal/startseite/verein/11/saison_id/2006" id="11">
      <img alt="Arsenal FC" class="" src="https://tmssl.akamaized.net/images/wappen/verysmall/11_1400911988.png?lm=1400911994" title=" "/>
     </a>
    </div>
    <div>
     <nobr>
      <a class="sb-vereinslink" href="/fc-arsenal/startseite/verein/11/saison_id/2006" id="11">
       Arsenal FC

The key here is that <div class="large-6 shows up twice, which is what I'm trying to split on.

The code I'm using is simply boxes = soup.find_All("div",{'class',re.compile(r'^large-6 columns')}) however that is returning absolutely nothing.

I've used BeautifulSoup successfully plenty of times before and I'm sure it's something stupid that I'm missing, but I've been banging my head against a wall for the last 2 hours and can't seem to figure it out. Any help would be much appreciated.

Upvotes: 0

Views: 67

Answers (1)

ncraig
ncraig

Reputation: 1193

My understanding is that Python is case sensitive. Thus, I think you need to make it soup.find_all rather than All. The code below ran with a working url.

url = "https://####.###"

import requests
from bs4 import BeautifulSoup
r = requests.get(url)
coverpage = r.content
soup = BeautifulSoup(coverpage, 'html5lib')

test = soup.find_all("a")
print(test)

When I made the all into All it broke with the following error:

test = soup.find_All("a")
TypeError: 'NoneType' object is not callable

Upvotes: 2

Related Questions