Microsoft 365 Probleme de code

Capuishon

XLDnaute Nouveau
bonjour j ai un probleme de code
je dois cree un programme pour ressencer tout les noms des magazins auchan dans un excel et j'ai 2 code qui ne marchent pas :

import requests
from bs4 import BeautifulSoup

url = "https://www.auchan.fr/magasins"
page = requests.get(url)
soup = BeautifulSoup(page.content, 'html.parser')

magasins = soup.find_all('div', class_='item-store')
for magasin in magasins:
nom = magasin.find('h3').text.strip()
adresse = magasin.find('p', class_='address-store').text.strip()
print(f"{nom} - {adresse}")



et celui la

Sub GetAuchanStores()

Dim IE As Object

Dim doc As HTMLDocument

Dim tbl As HTMLTable

Dim r As Long, c As Long

Dim elem As IHTMLElement



Set IE = CreateObject("InternetExplorer.Application")

With IE

.Visible = False

.Navigate "https://www.auchan.fr/nos-magasins?types=HYPER"

Do While .Busy Or .ReadyState <> 4: DoEvents: Loop

Set doc = .Document

End With



Set tbl = doc.getElementsByTagName("table")(0)



r = 1 'start row for data in excel sheet



For Each elem In tbl.Rows

c = 1 'start column for data in excel sheet



For Each cell In elem.Cells

Sheet1.Cells(r, c) = cell.innerText 'insert data into excel sheet



c = c + 1 'increment column counter for next cell in row

Next



r = r + 1 'increment row counter for next row of data in excel sheet

Next



End Sub

merci pour vos reponses
 

Discussions similaires

Réponses
12
Affichages
453

Statistiques des forums

Discussions
315 098
Messages
2 116 190
Membres
112 679
dernier inscrit
Yupanki