I am using following code to scrape data from a tabular structure present on a webpage using beautiful Soup:
# -*- coding: cp1252 -*-
import csv
import urllib2
import sys
import urllib
import time
import mechanize
from bs4 import BeautifulSoup
from itertools import islice
page = urllib2.urlopen('http://www.t-mobile.de/tarifuebersicht-telefonieren-und-surfen/0,23786,25241-_,00.html#grp=0&dev=0').read()
soup = BeautifulSoup(page)
for row in soup('table', {'class' : 'wloCol5'}).tbody('tr'):
tds = row['td']
print tds
This code is giving me AttributeError: 'ResultSet' object has no attribute 'tbody' error. I am using similar code for another webpage which is running without any glitches. Please advise what may be the issue with this code/webpage structure which is causing this error.
The call
soup('table', {...})finds more that one table, so it returns a list-like object.Try something like: