ProfLonghair
ProfLonghair

Reputation: 81

beginner python web scrape issue

I have the following html code:

<div class="panel panel-default box">
<div class="panel-heading">
<h2 class="panel-title">December 2015</h2>
</div>
<div class="panel-body">
<ul>
    <li>December 30, 2015 - <a href="link">Report</a></li>
    <li>December 23, 2015 - <a href="link">Report</a></li>
    <li>December 16, 2015 - <a href="link">Report</a></li>
    <li>December 9, 2015 - <a href="link">Report</a></li>
    <li>December 2, 2015 - <a href="link">Report</a></li>
</ul>
</div>
</div>

I wrote the following python code to scrape some of the content above.

from bs4 import BeautifulSoup
import lxml
import requests
import textwrap
import csv

BASE_URL = "link"
response = requests.get(BASE_URL)
html = response.content

#each monthly list starts with <div class="panel-body">
soup = BeautifulSoup(html,"lxml")

list_of_links = soup.findAll('div', attrbs={'class': "panel-body"})

print list_of_links

For some reason Python keeps returning an empty "list_of_links"

Does anyone know what I'm doing wrong?

Thanks.

Upvotes: 0

Views: 74

Answers (1)

masnun
masnun

Reputation: 11916

You seem to have a typo here:

attrbs={'class': "panel-body"})

Should be attrs, not attrbs.

Upvotes: 1

Related Questions