I have been trying to write a python script to allow me to harvest QR codes from whatsapp web. I use selenium but can't seem to get it to write.
The code I've got to so far does this:
import base64 from selenium import webdriver url = "https://web.whatsapp.com" init_search = "<img style=\"display: block;\" src=\"data:image/png;base64," term_search = "\"></div>" browser = webdriver.Firefox() browser.get(url) html_source = browser.page_source start = html_source.find(init_search) end = html_source[start:].find(term_search) raw_png = html_source[start+len(init_search):end] print html_source[start:end] print base64.b64decode(raw_png) browser.close()
But it's not really stable. How to do this, and if possible without actually opening the browser?