Q: TD list turn empty when I web scraping I try to get some weekly data in official banking sector data. However, even though the codes work properly, the list comes as an empty list.
My python code is as follows:
import requests
from bs4 import BeautifulSoup

import urllib.request
url="http://www.bddk.org.tr/BultenHaftalik"
r=requests.get(url)
html_content=r.text
soup=BeautifulSoup(html_content,"html.parser")

veri_tablosu=soup.find('table', class_='table table-bordered table-condensed verigostermetablosu responsive-table')

for veri in veri_tablosu.find_all('tbody'):
    rows=veri.find_all('tr')
    for row in rows:
        basliklar=row.find('td', class_= 'ortala')
        print(basliklar)


A: It looks like beautifulsoup is unable to find <tbody> and returns None instead of list of body elements.
Although you can try to extract <tr> directly from the table
veri_tablosu=soup.find('table', class_='table table-bordered table-condensed verigostermetablosu responsive-table')
for row in veri_tablosu.find_all('tr'):
    basliklar=row.find('td', class_= 'ortala')
    print(basliklar)  


A: The question is tobdy not in source html, so you cannot use find_all('tbody').

just use for veri in veri_tablosu.find_all('tr').

A: That is because <tbody> isn't present in the soup. So you get an empty result.
Instead of using <tbody>, you can directly select the rows <tr> with class name as satir (because that's where the data is) and extract the data you need.
Here is how the code looks like:
basliklar = []
for veri in veri_tablosu.findAll('tr', class_='satir'):
    basliklar.append(veri.find('td', class_= 'ortala').text)
print(basliklar)

Output

['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20']

