mercredi 28 avril 2021

How to mimic a browser which can refresh itself using Python request

Whenever we open up a webpage using web browser (Chrome), for example Wall Street journal https://www.wsj.com/. I can see that the webpage can refresh itself: sometime the headline automatically change, the stock index got update or get an ad push.

I am wondering how can the web browser realize such an "listen" state? If I also want to mimic that behavior in Python, how would I do?

Something I know so far:

  1. sending request every 1 seconds to scrape for any update.
  2. if there is a web socket, I can subscribe and keep running ws.recv() in a while loop



Aucun commentaire:

Enregistrer un commentaire