Я попробовал приведенный ниже код и добился небольшого успеха, но не знаю, как это сделать правильно, чтобы получить только информативный контент без элементов html/css в результатах.
Код: Выделить всё
from bs4 import BeautifulSoup as bs
import requests
url = 'https://ihgfdelhifair.in/mis/Exhibitors'
page = requests.get(url)
soup = bs(page.text, 'html')
[img]https://i.sstatic.net /QsmXDfgn.png[/img]
Код: Выделить всё
cards = soup.find_all('div', class_="row Exhibitor-Listing-box")
cards
Код: Выделить всё
[
[h4] 1 ARTIFACT DECOR (INDIA)[/b][/h4][b]
Email : artifactdecor01@gmail.com
Contact Person : SHEENU
State : UTTAR PRADESH
City : AGRA
Hall No. : 12
Stand No. : G-15/43
Mobile No. : +91-5624010111, +91-7055166000
Website : www.artifactdecor.com
Source Retail : Y
Vriksh Certified : N
Код: Выделить всё
for element in cards:
title = element.find_all('h4')
email = element.find_all('p')
print(title)
print(email)
Код: Выделить всё
[[h4] 1 ARTIFACT DECOR (INDIA)[/b][/h4], [h4][b] 10G HOUSE OF CRAFT[/b][/h4], [h4][b] 2 S COLLECTION[/b][/h4], ........]
[
Email : artifactdecor01@gmail.com
,
Contact Person : ..................]
Подробнее здесь: https://stackoverflow.com/questions/791 ... p-properly
Мобильная версия