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:
- sending request every 1 seconds to scrape for any update.
- if there is a web socket, I can subscribe and keep running
ws.recv()
in awhile
loop
Aucun commentaire:
Enregistrer un commentaire