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

368
Vistas
How to get something from a webpage with python

This page has a url https://www.example.com

<html>
<body>
<button id="button1" onclick=func1()>
<button id="button2" onclick=func2()>
</body>
<script>
function func1(){
  open("/doubt?s=AAAB_BCCCDD");
}

function func2(){
  open("/doubt?s=AABB_CCDDEE");
}
//something like that, it is working ....
</script>
</html>

AAAB_BCCCDD and AABB_CCDDEE - both are the tokens ...

i want to get the first token in the page with python
my python code -

import requests

r = requests.get("https://www.example.com")
s = r.text

if "/doubt?s=" in s:
# After this i can' understand anything ...
# i want to get the first token here as a variable

please help me ....

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

0

Usually, after fetching the website's raw text content, you would parse the HTML first using a library like BeautifulSoup. It will create a document object model (DOM) tree, which you then can query for the elements you need.

However, this won't read nor interpret JavaScript code. For your problem, you can use regular expressions to extract the necessary information from the raw text.

Example:

import re
import requests

r = requests.get("https://www.example.com")
s = r.text

pattern = re.compile('/doubt\\?s=(?P<token>\\w+)')
matches = pattern.findall(s)
if len(matches) > 0:
  print(matches[0])
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