Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

172
Vistas
Best way to get html text element on website and copy it to clipboard?

I constantly need to copy some text data from the same website. Copying it myself is tedious and what I would love to have is: When I enter that website, and this particular element (specified with XPath) has some text in it (it's not blank) then the script gets Text from this element and copies it to my clipboard.

It would be great if it would work in my Chrome browser. Is it something I could achieve with Python and Selenium for example?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you are just web scrapping then you really don't need selenium unless you need to input something or can't get there with just the URL. Just get the HTML and extract what you need.

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda