# importing package
from selenium import webdriver
# setting the path
PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
options = webdriver.ChromeOptions
options.headless = True
driver.get("https://www.craispesaonline.it/provincia/treviso")
# x path for Address and Postal Code
x = ('//address//p[@class="text-lowercase m-0 ng-binding"]')
search = driver.find_elements_by_xpath(x)
# retrieving the output in a text file
with open("Italy_Scrape.txt", "a") as f:
for i in search:
print("PostalCode :" + i.text, file=f)
print("----------------------------------------------------------------------------", file=f)
driver.quit()
获取邮政地址的代码。在上面的代码中,我使用的是无头 chrome 的 selenium。需要代码以仅获取可以送货的商店的邮政编码。
POPMUISE
开满天机
郎朗坤
相关分类