Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 99041

Getting element using re.compile with bs4?

$
0
0

i try to find a span element using selenium and bs4 with the following code:

import refrom bs4 import BeautifulSoupfrom selenium import webdriverfrom selenium.webdriver.chrome.options import Optionsfrom selenium.webdriver.chrome.service import Serviceimport timeoptions = Options()options.add_argument("start-maximized")  options.add_argument('--use-gl=swiftshader')options.add_argument('--enable-unsafe-webgpu')options.add_argument('--enable-unsafe-swiftshader')options.add_argument("--disable-3d-apis")options.add_argument('--disable-gpu')options.add_argument('--no-sandbox')options.add_argument('--disable-dev-shm-usage')options.add_argument("start-maximized")options.add_argument('--log-level=3')  options.add_experimental_option("prefs", {"profile.default_content_setting_values.notifications": 1})    options.add_experimental_option("excludeSwitches", ["enable-automation"])options.add_experimental_option('excludeSwitches', ['enable-logging'])options.add_experimental_option('useAutomationExtension', False)options.add_argument('--disable-blink-features=AutomationControlled') srv=Service()driver = webdriver.Chrome (service=srv, options=options)    driver.get ("https://www.local.ch/de/d/zuerich/8001/personalberatung/mooser-partner-ag-beratung-in-personalfragen-QUYNvCwYvBzZBco5HS626Q")     time.sleep(2) soup = BeautifulSoup (driver.page_source, 'lxml')      worker = soup.find("div", {"data-cy": "detail-map-preview"})worker = worker.find("span", string=re.compile('Adresse'))          print(worker)

But i allways get None as final output despite i can see "Adresse" in the span-element of the source-code.

How can i find this span-element with the text using re.compile?

enter image description here


Viewing all articles
Browse latest Browse all 99041

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>