How do I Extract ZIP code from a Website using selenium python

Muazma Tech

I am new to python selenium i want to extract

https://tools.keycdn.com/geo

tools.keycdn.com/geo

I need to extract only postal code i.e 10080

only zipcode not any other text

and print it out on screen

cruisepandey

There is a cookies accept button, so you need to accept that first, and then using //dt[text()='Postal code']//following-sibling::dd xpath you can extract the postal code. See below

Code:

driver = webdriver.Chrome(driver_path)
driver.maximize_window()
driver.get("https://tools.keycdn.com/geo")
wait = WebDriverWait(driver, 20)
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button[class*='alert-cookies']"))).click()

postal_code = wait.until(EC.visibility_of_element_located((By.XPATH, "//dt[text()='Postal code']//following-sibling::dd"))).text

print(postal_code)

Imports :

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do i extract data from yelp using selenium python

how can i extract this value from a website, with python, selenium and chromedriver

How to extract the product titles from the website using Selenium Python

How do i extract data from a live website with python?

How can I extract information from a HTML code using Python + Selenium?

How do I scrape ::before element in a website using selenium python

How do I wait for this website to load using selenium in Python?

How do I Extract ADDRESS info from a fakeaddressgenerator using selenium python

How do I extract the information from the website?

How to extract zip code from address using pandas function extract()?

How to extract a table from the website using python?

How to extract ec2 instance details like name, memory from aws website using python selenium

How can I extract the zip code from the ggmap output?

How do I extract a .jpg or .png from a website using a zoom window

Extract text of website using Selenium and Python

How can I get the tooltip text from a website using selenium and python where the text comes from a javascript

How can I extract and rename specific files from daily compressed zip folders using Python?

How do I obtain a list of values from a website dropdown using selenium?

How do I extract data from df ~ onto my website?

How do I download/extract font from a website?

How do I extract a text from a website(html)

How to extract data with selenium from a website?

Using Selenium+python to extract HTML code from a list of links

How do I extract a table from a webpage using selenium when the table is not constructed with the HTML 'table' tag?

How can I get and extract a number from website using Java?

How would I extract metadata from an external website using JavaScript?

How can i download specifcs files from a website using Python + Selenium

How can I extract a specific text in an html code with Selenium and Python

How can I extract outgoing links from a website in python?