【发布时间】:2020-07-31 15:00:04
【问题描述】:
# 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()
获取邮政地址的代码。 在上面的代码中,我使用的是无头铬的硒。 只需要该代码来获取可以送货的商店的邮政编码。
【问题讨论】:
标签: python selenium xpath web-scraping webdriverwait