Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

157
Views
Cómo acceder al texto principal que no tiene etiqueta a través de xPath

Encuentre el código a continuación

 <div class="xsmall-12 medium-6 columns"> <label class="device-attribute-label" rel="tooltip" title="Proprietary/trade name of the medical device as used in the labeling or catalog.">Brand Name:</label> Snowden-Pencer <br> <label class="device-attribute-label" rel="tooltip" title="Identifies a category or design of devices that have specifications, performance, size, and composition within limits set by the company.">Version or Model:</label> 32-0044 <br> <label class="device-attribute-label" href="#" rel="tooltip" title="Whether the device is currently offered for sale by the device company. A device no longer in commercial distribution may or may not still be available for purchase in the marketplace.">Commercial Distribution Status:</label> In Commercial Distribution <br> <label class="device-attribute">Catalog Number:</label> 32-0044 <br> <label class="device-attribute">Company Name:</label> CAREFUSION 2200, INC </div>

Tengo que recuperar el texto principal como "Snowden-Pencer", "32-0044","CAREFUSION 2200, INC" individualmente

Esto es lo que he probado

 element = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.XPATH, "/html/body/div[1]/div[1]/div[2]/div[1]/div[2]/section[1]/div[1]/div[1]//div[1]/*")) )

La salida es:

 output = Brand Name:

Necesito encontrar el XPath correcto. Por favor ayúdenme, gracias de antemano

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Si está usando selenio, puede usar el método getText() , por lo que tal vez se verá como driver.findElement(webdriver.By.xpath("XPath")).getText() Aunque eso es para Java.

Para python creo que se parece a esto

value_text = driver.find_element_by_xpath("XPath").text

about 4 years ago · Juan Pablo Isaza Report

0

¿Puedes probar debajo de dos xpaths?

 //label[@rel='toltip']/*
about 4 years ago · Juan Pablo Isaza Report

0

puedes usar expresiones regulares

 import re a = """<div class="xsmall-12 medium-6 columns"> <label class="device-attribute-label" rel="tooltip" title="Proprietary/trade name of the medical device as used in the labeling or catalog.">Brand Name:</label> Snowden-Pencer <br> <label class="device-attribute-label" rel="tooltip" title="Identifies a category or design of devices that have specifications, performance, size, and composition within limits set by the company.">Version or Model:</label> 32-0044 <br> <label class="device-attribute-label" href="#" rel="tooltip" title="Whether the device is currently offered for sale by the device company. A device no longer in commercial distribution may or may not still be available for purchase in the marketplace.">Commercial Distribution Status:</label> In Commercial Distribution <br> <label class="device-attribute">Catalog Number:</label> 32-0044 <br> <label class="device-attribute">Company Name:</label> CAREFUSION 2200, INC </div>""" b = re.findall(r' (.*?)\n', a) c = [x.lstrip().rstrip() for x in b if '<' not in x and '>' not in x]
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!