ya Sheri
ya Sheri

Reputation: 1

How to extract URL from browser search bar Python? Lack of knowledge

Wrote a script in python selenium that enters the page, enters the number and presses the button, then goes to the new URL. How can I extract the URL I'm on from the browser's address bar?

import pandas as pd
from bs4 import BeautifulSoup
import requests
from urllib.parse import urlparse, urljoin
from selenium import webdriver

r = requests.get('https://kadbase.ru')

browser = webdriver.Chrome()
browser.get('https://kadbase.ru')

text_area_xpath = '/html/body/div/div[4]/div[1]/div[1]/div/div[2]/form/div[2]/input[1]'
browser.find_element_by_xpath(text_area_xpath).send_keys('45:25:020101:1481')

button_xpath = '/html/body/div/div[4]/div[1]/div[1]/div/div[2]/form/div[2]/input[2]'
browser.find_element_by_xpath(button_xpath).click()

Upvotes: 0

Views: 336

Answers (1)

Ryan
Ryan

Reputation: 1181

You should be able to grab the current url using browser.current_url

Upvotes: 2

Related Questions