у меня есть такой код:
def get_html_hidemy(site):
r = requests.get(site)
return r.text
def get_page_data_hidemy(html):
soup = BeautifulSoup(html, 'lxml')
line = soup.find_all('div', class_='table_block').find("table").find('tbody').find_all('tr')
for tr in line:
td = tr.find_all('td')
ip = td[0].text
port = td[1].text
country = td[2].text.replace('\xa0', '')
types = td[4].text.replace('\r\n\t\t\t\t\t', '').replace('\r\n ', '')
data = {'ip': ip,
'Порт': port,
'Страна': country,
'Тип': types}
print(data)
def hidemy():
url_hidemy = 'https://hidemy.name/ru/proxy-list/#list'
get_page_data_hidemy(get_html_hidemy(url_hidemy))
if __name__ == '__main__':
hidemy()
и пишет ошибку:
Traceback (most recent call last):
File "C:\Users\Иван\AppData\Local\Programs\Python\Python38\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\Users\Иван\AppData\Local\Programs\Python\Python38\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\Иван\Desktop\pypi\bot_bomber_admin.py", line 105, in hidemy
get_page_data_hidemy(get_html_hidemy(url_hidemy))
File "C:\Users\Иван\Desktop\pypi\bot_bomber_admin.py", line 79, in get_page_data_hidemy
line = soup.find_all('table', class_='table_block').find('tbody').find_all('tr')
File "C:\Users\Иван\AppData\Local\Programs\Python\Python38\lib\site-packages\bs4\element.py", line 2173, in __getattr__
raise AttributeError(
AttributeError: ResultSet object has no attribute 'find'. You're probably treating a list of elements like a single element. Did you call find_all() when you meant to call find()?
что я делаю не так?
line = soup.find_all('div', class_='table_block')
замените наline = soup.find('div', class_='table_block')