JavaScript Harvest JS generated Image URI using SeleniumJS

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 QR image is a PNG generated by a javascript live (hence selenium) in which it is converted to a PNG in Base64 and translated by the browser to an image.

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?

Answer:1

I am customising Sage CRM, so I have no control over the HTML that is written and can't add IDs or class's to the table layouts the CRM spits out. I want to hide a higher (not top) level table based ...

I am customising Sage CRM, so I have no control over the HTML that is written and can't add IDs or class's to the table layouts the CRM spits out. I want to hide a higher (not top) level table based ...

  1. jquery find parent with class
  2. jquery find parent element
  3. jquery find parent tr
  4. jquery find parent div
  5. jquery find parent form
  6. jquery find parent with attribute
  7. jquery find parent with id
  8. jquery find parent with class name
  9. jquery find parent td
  10. jquery find parent table
  11. jquery find parent li
  12. jquery find parent of parent
  13. jquery find parent row
  14. jquery find parent matching selector
  15. jquery find parent sibling child
  16. jquery find parent or grandparent
  17. jquery find parent with data attribute
  18. jquery find parent until
  19. jquery find parent sibling
  20. jquery find parent tr of td

I hope questions from beginners are acceptable. I don't mind studying, but based on research so far, I'm not sure where to even begin........ I'm in need of a script that can fit into a small URI ...

I hope questions from beginners are acceptable. I don't mind studying, but based on research so far, I'm not sure where to even begin........ I'm in need of a script that can fit into a small URI ...

I have a javascript code like this and this always gives me a problem for(var i=1;i<9;i++){ document.getElementById('element'+i).onclick=function(){ theFunc(i) } ...

I have a javascript code like this and this always gives me a problem for(var i=1;i<9;i++){ document.getElementById('element'+i).onclick=function(){ theFunc(i) } ...

  1. writing javascript variable in html
  2. writing javascript in variable

I have a leaflet map and I want to assign colors to each "feature." The number of features can be different depending on changing geojson data. I am guessing there is some algorithm to do this. Here ...

I have a leaflet map and I want to assign colors to each "feature." The number of features can be different depending on changing geojson data. I am guessing there is some algorithm to do this. Here ...