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

190
Vistas
Save a blob PDF file with Selenium

I'm trying to download a blob PDF file with Selenium. The source page doesn't contain a link to this PDF, the link is created "on the fly", so I make some manipulations on the site, get "blob:https://.." link and run the JS below to get this file:

function blobToString(b) {
    var u, x;
    u = URL.createObjectURL(b);
    x = new XMLHttpRequest();
    x.open('GET', u, false);
    x.send();
    URL.revokeObjectURL(u);
    return x.responseText;
}

var xhr = new XMLHttpRequest();
xhr.open('GET', 'blob:https://...........', true);
xhr.responseType = 'blob';
xhr.onload = function(e) {
  if (this.status == 200) {
    var myBlob = this.response;
 
document.querySelector("body").setAttribute("test",blobToString(myBlob));

  }
};
xhr.send();

So, for now I'm able to get this blob PDF to Selenium by saving it's content to some element's attribute and getting it to the Selenium after that.

The problem is that PDF doesn't open as a normal file, some of it's content is coded with strange symbols:

Downloaded with Selenium: �0 ��W�Ǻ�M�D�J��B�B� Q��P �oﵜ��w�,��� Y�4���E\4~�310�4���bk� �� ɔ�4}p� �\uq���zwcN��i��i��c�V���տ � �

Downloaded manually: Â0^T<85>áWùǺ¤MÒDçJÅÅBáBç^NQ<94>¦P^U±oïµ<9c>åÀwà,ô<94>ò¥¹^\Y¨4¡òÆE\4~Ï310«4<82>ÝØbk¥^CÁÔ^QÉ<94>ç4}pÖ^D<8f>\uq£<90>ôzwcNüËiÌ÷iÝÉc³Vô±§Õ¿^_^\³^^×

So I need to perform some kind of encoding/decoding to make it work. Please, help with this.

about 4 years ago · Juan Pablo Isaza
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