S
S
Stepan Sidorov2020-04-18 10:24:03
Python
Stepan Sidorov, 2020-04-18 10:24:03

How to separate same python bs4 classes?

I need to separate the information (text) and put it in the lists, but alas, it is under the same classes and the standard findAll methods cannot be divided.
5e9aaae791d16886441832.png.
How can I do that?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Karbivnichy, 2020-04-18
@Stepan47

import requests
from bs4 import BeautifulSoup

response = requests.get('https://www.roseltorg.ru/procedure/0114500000820000578')
soup = BeautifulSoup(response.text,"html.parser")
table = soup.find_all('table',class_='lot-item__data-table')[1]
info_ = table.find_all('p',class_='data-table__info')

inn = info_[0].text
name = info_[1].text
address = info_[2].text
phone = info_[3].text
mail = info_[4].text
place = info_[5].text

print(f'''ИНН: {inn}
Название орг: {name}
Адрес: {address}
Телефон: {phone}
E-mail: {mail}
Место проведения: {place}
''')

There are no checks here! From the first page, everything worked, except for the first procedure (but the number in this procedure is somehow short) and it does not contain all the information.

D
Dimonchik, 2020-04-18
@dimonchik2013

xpath
+ ordinal number of the element
or by substring

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question