skip to Main Content

I want to extract all HTML elements from Telegram web website. I tried all methods e.g. get, post, get() jquery, methods from Python, JavaScript, …

But when they return the result, it is incomplete and some part of it is missing. How can I do this correctly?

This a snippet that returns an incomplete alements:

fetch("https://web.telegram.org/k/")
  .then(x => x.text())
  .then(y => console.log(y));

3

Answers


  1. Chosen as BEST ANSWER

    I learned for Telegram Web scraping, we cannot use the traditional javascript codes or simple Python library. In this case, we MUST use Selenium and WebDriver and I'm working on it. Any better suggestion will be appreciated.


  2. try this way,

    // first install jsdom
    // type npm i jsdom in the console.
    
    const jsdom = require("jsdom");
    const { JSDOM } = jsdom;
    
    fetch("https://web.telegram.org/k/")
        .then(x => x.text())
        .then(y => {
            const { document } = (new JSDOM(y)).window;
            console.log(document)
    });
    
    

    checkout jsdom documantation:
    https://github.com/jsdom/jsdom

    Login or Signup to reply.
  3. did you try to add header: "Application-Type" :"text/html"

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search