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

167
Views
¿La mejor manera de obtener un elemento de texto html en el sitio web y copiarlo en el portapapeles?

Constantemente necesito copiar algunos datos de texto del mismo sitio web. Copiarlo yo mismo es tedioso y lo que me encantaría tener es: cuando entro en ese sitio web, y este elemento en particular (especificado con XPath) tiene algo de texto (no está en blanco), entonces el script obtiene el texto de este elemento y lo copia. a mi portapapeles.

Sería genial si funcionara en mi navegador Chrome. ¿Es algo que podría lograr con Python y Selenium, por ejemplo?

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

0

Si solo está eliminando web, entonces realmente no necesita selenio a menos que necesite ingresar algo o no pueda llegar solo con la URL. Simplemente obtenga el HTML y extraiga lo que necesita.

 import pyperclip import time from bs4 import BeautifulSoup import requests def get_page_html(url): headers = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36"} page = requests.get(url, headers=headers) return page.content def parse_html(url): page_contents = get_page_html(url) soup = BeautifulSoup(page_contents, 'html.parser') divs = soup.find("div", {"class": "fulfillment-fulfillment-summary"}) return divs.encode_contents() pyperclip.copy(parse_html(<URL>)) s = pyperclip.paste()#If needed
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!