Issue
I just started programming for my job and I am stuck on something. I looked online before but none of the answers seemed to work. I am using BeautifulSoup but Im open to using something else. Thank you so much!
I am trying to extract the names in <div class="single_liste_exposant_name">
names </div>
So far I have
from bs4 import BeautifulSoup
with open("C:\\Users\\marle\\Desktop\\texte.txt", 'rb') as fp:
soup = BeautifulSoup(fp)
soup = BeautifulSoup("<html>data</html>")
name_list = soup.find_all"(class=\"single_liste_exposant_name\"></div)"
print (name_list)
</div>
</a>
</div>
<div class="single_liste_exposant">
<div class="btn_ajout_selection"><a class="LinkIn bouton selection" href="/en/visit/list-of-exhibitors/selection/?id=61448&type=exposant">Ajouter à ma sélection</a></div>
<a href="display-entry-61448.html" hreflang="fr" title="A. FABRE" class="LinkIn">
<div class="single_liste_exposant_picto">
</div>
<div class="single_liste_exposant_name">
A. FABRE
</div>
<div class="single_liste_exposant_emplacement">
<span>Hall </span>GP -
<span>Allée </span>H -
<span>Stand </span>547
</div>
<div class="single_liste_exposant_description">
The Company a.frabre has set up in Saumur more than a century ago ot serve the needs of clients: industries, wine growers, craftsmen, etc. It is made up of a dozen of experienced employees and enjoys a strong regional recognition thanks to the quality of its services, its customised answers to clients and its expertise.
</div>
<div id="specific">
</div>
</a>
</div>
<div class="single_liste_exposant">
<div class="btn_ajout_selection"><a class="LinkIn bouton selection" href="/en/visit/list-of-exhibitors/selection/?id=61314&type=exposant">Ajouter à ma sélection</a></div>
<a href="display-entry-61314.html" hreflang="fr" title="A.B. PROCESS INGENIERIE" class="LinkIn">
<div class="single_liste_exposant_picto">
</div>
<div class="single_liste_exposant_name">
A.B. PROCESS INGENIERIE
</div>
<div class="single_liste_exposant_emplacement">
<span>Hall </span>GP -
<span>Allée </span>G -
<span>Stand </span>525
</div>
<div class="single_liste_exposant_description">
Design and manufacturing of conveyor belts and handling systems, of special machines for robotisation and automation as well as IT for production units
</div>
<div id="specific">
</div>
</a>
</div>
<div class="single_liste_exposant">
<div class="btn_ajout_selection"><a class="LinkIn bouton selection" href="/en/visit/list-of-exhibitors/selection/?id=61603&type=exposant">Ajouter à ma sélection</a></div>
<a href="display-entry-61603.html" hreflang="fr" title="A.D.I.VALOR" class="LinkIn">
<div class="single_liste_exposant_picto">
</div>
<div class="single_liste_exposant_name">
A.D.I.VALOR
</div>
<div class="single_liste_exposant_emplacement">
<span>Hall </span>D -
<span>Allée </span>B -
<span>Stand </span>242
</div>
<div class="single_liste_exposant_description">
A.d.i..valor (farmers and industrial distributors for the upcycling of agricultural wastes) is the eco-agency of agriculture. a.d.i.valor manages three flows of agricultural waste:- empty packages (having contained phytopharmaceutical products, fertilisers, seeds, hygiene or wine related products),- used plastics (films, strings, nets, irrigation hoses),- hazardous wastes (non-used phytosanitary products, individual protection equipment, phytopharmaceutical effluent wastes).
</div>
<div id="specific">
</div>
</a>
</div>
<div class="single_liste_exposant">
<div class="btn_ajout_selection"><a class="LinkIn bouton selection" href="/en/visit/list-of-exhibitors/selection/?id=61557&type=exposant">Ajouter à ma sélection</a></div>
<a href="display-entry-61557.html" hreflang="fr" title="ABA" class="LinkIn">
<div class="single_liste_exposant_picto">
</div>
<div class="single_liste_exposant_name">
ABA
</div>
<div class="single_liste_exposant_emplacement">
<span>Hall </span>NOV -
<span>Allée </span> -
<span>Stand </span>335
</div>
<div class="single_liste_exposant_description">
Modular, pu-pvc-ca-mesh conveyor belts. Belts for grape-harvesters, steel, aluminium and pvc reels. Drums, engines, conveyor belts for the transport and sorting of products. All types of specific belt designs. Drum, cylinder and plate hot mounting presses, etc.
</div>
<div id="specific">
</div>
</a>
</div>
<div class="single_liste_exposant">
<div class="btn_ajout_selection"><a class="LinkIn bouton selection" href="/en/visit/list-of-exhibitors/selection/?id=61445&type=exposant">Ajouter à ma sélection</a></div>
<a href="display-entry-61445.html" hreflang="fr" title="ACTION PIN" class="LinkIn">
<div class="single_liste_exposant_picto">
</div>
<div class="single_liste_exposant_name">
ACTION PIN
</div>
<div class="single_liste_exposant_emplacement">
<span>Hall </span>GP -
<span>Allée </span>G -
<span>Stand </span>515
</div>
<div class="single_liste_exposant_description">
Manufacturer of pinewood terpene based additives and fungicides
</div>
<div id="specific">
</div>
</a>
</div>
<div class="single_liste_exposant">
<div class="btn_ajout_selection"><a class="LinkIn bouton selection" href="/en/visit/list-of-exhibitors/selection/?id=61396&type=exposant">Ajouter à ma sélection</a></div>
<a href="display-entry-61396.html" hreflang="fr" title="ACTISOL" class="LinkIn">
<div class="single_liste_exposant_picto">
</div>
<div class="single_liste_exposant_name">
ACTISOL
</div>
<div class="single_liste_exposant_emplacement">
<span>Hall </span>GP -
<span>Allée </span>G -
<span>Stand </span>469
</div>
<div class="single_liste_exposant_description">
Actisol supports your cropping systems in order to upgrade your soil while preserving the environment and reducing economic constraints. Actisol sells machines that have been specially disigned for an agronomic work. The fine and fluid Actisol tooth is mounted on a full range of machines. Our company operates in the following sectors: large crops, wine growing, market gardening, arboriculture and mechanised equipment to meet the needs of everyone.
</div>
<div id="specific">
</div>
</a>
</div>
<div class="single_liste_exposant">
<div class="btn_ajout_selection"><a class="LinkIn bouton selection" href="/en/visit/list-of-exhibitors/selection/?id=61222&type=exposant">Ajouter à ma sélection</a></div>
<a href="display-entry-61222.html" hreflang="fr" title="ACTISOL" class="LinkIn">
<div class="single_liste_exposant_picto">
</div>
<div class="single_liste_exposant_name">
ACTISOL
</div>
<div class="single_liste_exposant_emplacement">
<span>Hall </span>C -
<span>Allée </span> -
<span>Stand </span>212
</div>
<div class="single_liste_exposant_description">
Equipment for soil work in between rows and vine stocks
</div>
<div id="specific">
</div>
</a>
</div>
<div class="single_liste_exposant">
<div class="btn_ajout_selection"><a class="LinkIn bouton selection" href="/en/visit/list-of-exhibitors/selection/?id=61491&type=exposant">Ajouter à ma sélection</a></div>
<a href="display-entry-61491.html" hreflang="fr" title="ADAMA FRANCE" class="LinkIn">
<div class="single_liste_exposant_picto">
</div>
<div class="single_liste_exposant_name">
ADAMA FRANCE
</div>
<div class="single_liste_exposant_emplacement">
<span>Hall </span>GP -
<span>Allée </span>F -
<span>Stand </span>493
</div>
<div class="single_liste_exposant_description">
Adama sells plant protection simple solutions that bring a real advantage to tree growers and wine growers. Brevis, Klartan, Merpan, SC, Merpan, 80 wdg, Nimrod, Galway.
</div>
<div id="specific">
</div>
</a>
</div>
<div class="single_liste_exposant">
<div class="btn_ajout_selection"><a class="LinkIn bouton selection" href="/en/visit/list-of-exhibitors/selection/?id=61436&type=exposant">Ajouter à ma sélection</a></div>
<a href="display-entry-61436.html" hreflang="fr" title="ADI CARBURES" class="LinkIn">
<div class="single_liste_exposant_picto">
</div>
<div class="single_liste_exposant_name">
ADI CARBURES
</div>
<div class="single_liste_exposant_emplacement">
<span>Hall </span>GP -
<span>Allée </span>E-G -
<span>Stand </span>463
</div>
<div class="single_liste_exposant_description">
Manufacture of tungsten carbide wear parts for vineyards, market gardening, arboriculture and field crops.
</div>
<div id="specific">
</div>
</a>
</div>
<div class="single_liste_exposant">
<div class="btn_ajout_selection"><a class="LinkIn bouton selection" href="/en/visit/list-of-exhibitors/selection/?id=61327&type=exposant">Ajouter à ma sélection</a></div>
<a href="display-entry-61327.html" hreflang="fr" title="ADVANSEE" class="LinkIn">
<div class="single_liste_exposant_picto">
</div>
<div class="single_liste_exposant_name">
ADVANSEE
</div>
<div class="single_liste_exposant_emplacement">
<span>Hall </span>GP -
<span>Allée </span>I -
<span>Stand </span>587
</div>
<div class="single_liste_exposant_description">
Development and marketing of connected systems for eco-agrisystem biodiversity inventories. Vision based devices for early diagnoses and plant characterising.
</div>
<div id="specific">
</div>
</a>
</div>
<div class="single_liste_exposant">
<div class="btn_ajout_selection"><a class="LinkIn bouton selection" href="/en/visit/list-of-exhibitors/selection/?id=61073&type=exposant">Ajouter à ma sélection</a></div>
<a href="display-entry-61073.html" hreflang="fr" title="AESEA Group" class="LinkIn">
<div class="single_liste_exposant_picto">
</div>
<div class="single_liste_exposant_name">
AESEA Group
</div>
<div class="single_liste_exposant_emplacement">
<span>Hall </span>ARD -
<span>Allée </span>C -
<span>Stand </span>36
</div>
<div class="single_liste_exposant_description">
Marketing of off-soil crop substrates for market gardening and horticulture. Brands: orgapin, van der knaap, evo support , kekkila , meegaa and fertil'aquitaine. Substrates for young seedlings, plugs and tray-plants.
</div>
<div id="specific">
</div>
</a>
</div>
<div class="single_liste_exposant">
<div class="btn_ajout_selection"><a class="LinkIn bouton selection" href="/en/visit/list-of-exhibitors/selection/?id=61018&type=exposant">Ajouter à ma sélection</a></div>
<a href="display-entry-61018.html" hreflang="fr" title="AGENCE VITIOLE F.R.A" class="LinkIn">
<div class="single_liste_exposant_picto">
</div>
<div class="single_liste_exposant_name">
AGENCE VITIOLE F.R.A
</div>
<div class="single_liste_exposant_emplacement">
<span>Hall </span>AMP -
<span>Allée </span>I -
<span>Stand </span>656
</div>
<div class="single_liste_exposant_description">
Manufacturer of staples for vine lifting, attaches for stick bending and any other types of attaches for vine tying up
</div>
<div id="specific">
</div>
</a>
</div>
<div class="single_liste_exposant">
<div class="btn_ajout_selection"><a class="LinkIn bouton selection" href="/en/visit/list-of-exhibitors/selection/?id=61544&type=exposant">Ajouter à ma sélection</a></div>
<a href="display-entry-61544.html" hreflang="fr" title="AGRALIS" class="LinkIn">
<div class="single_liste_exposant_picto">
</div>
<div class="single_liste_exposant_name">
AGRALIS
</div>
<div class="single_liste_exposant_emplacement">
<span>Hall </span>NOV -
<span>Allée </span> -
<span>Stand </span>296
</div>
<div class="single_liste_exposant_description">
Technical solutions for the monitoring of watering and weather conditions: Sentek capacitive probes, aqualis.fr web interface, aqualis recorder, customised watering consulting, tinytag temperature monitoring.
</div>
<div id="specific">
</div>
</a>
</div>
<div class="single_liste_exposant">
<div class="btn_ajout_selection"><a class="LinkIn bouton selection" href="/en/visit/list-of-exhibitors/selection/?id=61605&type=exposant">Ajouter à ma sélection</a></div>
<a href="display-entry-61605.html" hreflang="fr" title="AGRAUXINE" class="LinkIn">
<div class="single_liste_exposant_picto">
</div>
<div class="single_liste_exposant_name">
AGRAUXINE
</div>
<div class="single_liste_exposant_emplacement">
<span>Hall </span>GP -
<span>Allée </span>E -
<span>Stand </span>448
</div>
<div class="single_liste_exposant_description">
Biocontrol and biostimulating products
</div>
<div id="specific">
<div class="repbio"><img src="/images/bio.png" alt="Répertoire bio"/></div>
</div>
</a>
</div>
<div class="single_liste_exposant">
<div class="btn_ajout_selection"><a class="LinkIn bouton selection" href="/en/visit/list-of-exhibitors/selection/?id=61321&type=exposant">Ajouter à ma sélection</a></div>
<a href="display-entry-61321.html" hreflang="fr" title="AGRAUXINE" class="LinkIn">
<div class="single_liste_exposant_picto">
<img src="/media/agrauxine_1.png"/>
</div>
<div class="single_liste_exposant_name">
AGRAUXINE
</div>
<div class="single_liste_exposant_emplacement">
<span>Hall </span>GP -
<span>Allée </span>E -
<span>Stand </span>448
</div>
<div class="single_liste_exposant_description">
Biocontrol and biostimulating products
</div>
<div id="specific">
</div>
</a>
</div>
<div class="single_liste_exposant">
<div class="btn_ajout_selection"><a class="LinkIn bouton selection" href="/en/visit/list-of-exhibitors/selection/?id=61141&type=exposant">Ajouter à ma sélection</a></div>
<a href="display-entry-61141.html" hreflang="fr" title="AGRI SYMBIOSE" class="LinkIn">
<div class="single_liste_exposant_picto">
</div>
<div class="single_liste_exposant_name">
AGRI SYMBIOSE
</div>
<div class="single_liste_exposant_emplacement">
<span>Hall </span>B -
<span>Allée </span>C-D -
<span>Stand </span>160
</div>
<div class="single_liste_exposant_description">
Organic nutrition and natural bio-stimulation of crops
</div>
<div id="specific">
</div>
</a>
</div>
<div class="single_liste_exposant">
<div class="btn_ajout_selection"><a class="LinkIn bouton selection" href="/en/visit/list-of-exhibitors/selection/?id=61072&type=exposant">Ajouter à ma sélection</a></div>
<a href="display-entry-61072.html" hreflang="fr" title="AGRIPOLYANE" class="LinkIn">
<div class="single_liste_exposant_picto">
</div>
<div class="single_liste_exposant_name">
AGRIPOLYANE
</div>
<div class="single_liste_exposant_emplacement">
<span>Hall </span>ARD -
<span>Allée </span>A -
<span>Stand </span>22
</div>
<div class="single_liste_exposant_description">
Transformer of polyethylene film for farm usage
</div>
<div id="specific">
<div class="repbio"><img src="/images/bio.png" alt="Répertoire bio"/></div>
</div>
</a>
</div>
<div class="single_liste_exposant">
<div class="btn_ajout_selection"><a class="LinkIn bouton selection" href="/en/visit/list-of-exhibitors/selection/?id=61409&type=exposant">Ajouter à ma sélection</a></div>
<a href="display-entry-61409.html" hreflang="fr" title="AGRISYNERGIE - SOKA" class="LinkIn">
<div class="single_liste_exposant_picto">
</div>
<div class="single_liste_exposant_name">
AGRISYNERGIE - SOKA
</div>
<div class="single_liste_exposant_emplacement">
<span>Hall </span>GP -
<span>Allée </span>I -
<span>Stand </span>606
</div>
<div class="single_liste_exposant_description">
We sell fertilisation (fertilisers/soil improvers) and protection (biocontrol: sokalciarbo/baïkal) solutions for all conventianal and ab. Crops. Our insect repellent mineral barrier (sokalciarbo/baïkal) can be used against 18 different species of pests up to date. Formulation for input to the soil and on leaves: granules, micro-granules, pellets, powders, liquids.
</div>
<div id="specific">
</div>
</a>
</div>
<div class="single_liste_exposant">
<div class="btn_ajout_selection"><a class="LinkIn bouton selection" href="/en/visit/list-of-exhibitors/selection/?id=61703&type=exposant">Ajouter à ma sélection</a></div>
<a href="display-entry-61703.html" hreflang="fr" title="AGROASIS-HKP" class="LinkIn">
<div class="single_liste_exposant_picto">
</div>
<div class="single_liste_exposant_name">
AGROASIS-HKP
</div>
<div class="single_liste_exposant_emplacement">
<span>Hall </span>B -
<span>Allée </span>B-C -
<span>Stand </span>132
</div>
<div class="single_liste_exposant_description">
Overall management of greenhouses (climate computers, irrigation, wheather, processing equipment)
</div>
<div id="specific">
</div>
</a>
</div>
<div class="single_liste_exposant">
<div class="btn_ajout_selection"><a class="LinkIn bouton selection" href="/en/visit/list-of-exhibitors/selection/?id=61408&type=exposant">Ajouter à ma sélection</a></div>
<a href="display-entry-61408.html" hreflang="fr" title="AGROFERTIL" class="LinkIn">
<div class="single_liste_exposant_picto">
</div>
<div class="single_liste_exposant_name">
AGROFERTIL
</div>
<div class="single_liste_exposant_emplacement">
<span>Hall </span>GP -
<span>Allée </span>E -
<span>Stand </span>443
</div>
<div class="single_liste_exposant_description">
Distribution of algae based materials and products. Biostimulants, organic leaf fertilisers.
</div>
<div id="specific">
</div>
</a>
</div>
<div class="single_liste_exposant">
<div class="btn_ajout_selection"><a class="LinkIn bouton selection" href="/en/visit/list-of-exhibitors/selection/?id=61368&type=exposant">Ajouter à ma sélection</a></div>
<a href="display-entry-61368.html" hreflang="fr" title="AGROFROST" class="LinkIn">
<div class="single_liste_exposant_picto">
</div>
<div class="single_liste_exposant_name">
AGROFROST
</div>
<div class="single_liste_exposant_emplacement">
<span>Hall </span>GP -
<span>Allée </span>D -
<span>Stand </span>417
</div>
<div class="single_liste_exposant_description">
Anti-frost machine
</div>
<div id="specific">
</div>
</a>
</div>
<div class="single_liste_exposant">
<div class="btn_ajout_selection"><a class="LinkIn bouton selection" href="/en/visit/list-of-exhibitors/selection/?id=61371&type=exposant">Ajouter à ma sélection</a></div>
<a href="display-entry-61371.html" hreflang="fr" title="AIMA GROUPE - MOTOCULTURE CHALLANDAISE" class="LinkIn">
<div class="single_liste_exposant_picto">
</div>
<div class="single_liste_exposant_name">
AIMA GROUPE - MOTOCULTURE CHALLANDAISE
</div>
<div class="single_liste_exposant_emplacement">
<span>Hall </span>GP -
<span>Allée </span>E -
<span>Stand </span>458
</div>
<div class="single_liste_exposant_description">
Trade and after sales service of equipment for agriculture, market gardening and wine growing.
</div>
<div id="specific">
</div>
</a>
</div>
<div class="single_liste_exposant">
<div class="btn_ajout_selection"><a class="LinkIn bouton selection" href="/en/visit/list-of-exhibitors/selection/?id=61337&type=exposant">Ajouter à ma sélection</a></div>
<a href="display-entry-61337.html" hreflang="fr" title="ALAIN BETEAU" class="LinkIn">
<div class="single_liste_exposant_picto">
</div>
<div class="single_liste_exposant_name">
ALAIN BETEAU
</div>
<div class="single_liste_exposant_emplacement">
<span>Hall </span>GP -
<span>Allée </span>H-I -
<span>Stand </span>571
</div>
<div class="single_liste_exposant_description">
Packaging of wines on the estate. Screw closures, labelling and packing of wines on the estate. Filtration: earth, must deposits, thermal vinification, argol stabilisation. ISO 9001 certified company.
</div>
<div id="specific">
</div>
</a>
</div>
<div class="single_liste_exposant">
<div class="btn_ajout_selection"><a class="LinkIn bouton selection" href="/en/visit/list-of-exhibitors/selection/?id=61357&type=exposant">Ajouter à ma sélection</a></div>
<a href="display-entry-61357.html" hreflang="fr" title="ALLTECH" class="LinkIn">
<div class="single_liste_exposant_picto">
</div>
<div class="single_liste_exposant_name">
ALLTECH
</div>
<div class="single_liste_exposant_emplacement">
<span>Hall </span>GP -
<span>Allée </span>G -
<span>Stand </span>496
</div>
<div class="single_liste_exposant_description">
Alltech Crop Science, as a subsidiary of Alltech, provides natural products and solutions to agronomy and horticulture in order to meet the challenges of all producers around.
</div>
<div id="specific">
<div class="repbio"><img src="/images/bio.png" alt="Répertoire bio"/></div>
</div>
</a>
</div>
Solution
You can find the div and then get the text:
from bs4 import BeautifulSoup
soup = BeautifulSoup(my_html)
names = [s.text.strip() for s in soup.findAll("div", attrs={"class":"single_liste_exposant_name"})]
print(names)
You just put your HTML string in my_html
Answered By - Bruno Mello
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.