I’m using the module ( re, uuid ) to capture the mac address and handle the result obtained. Running pyscript I get a different and changeable mac address when I reload the html page. Testing in pure python code I can get true mac address which is static and immutable.
Why is the mac address obtained is the fake and dynamic one using Pyscript?
How do I get the real mac address using Pyscript?
Below is the code example:
import re, uuid print (':'.join(re.findall('..', '%012x' % uuid.getnode())))
Using purely python language, I can get my original mac address, I think ( uuid.getnode() ), has nothing to do with it! Already using ( pyscript ) the result I have is a different and dynamic mac address when the html page is loaded.
Regarding the reason for use, it’s for security reasons.
uuid.getnode() is how Python is retrieving your hardware mac address when you run your code locally. Your example code is using the re (regex) module to parse and format the 48-bit number it returns as a MAC address. When uuid.getnode() fails to find an answer, it picks a random number each time, hence the “dynamic” address you’re seeing. See the documentation on that function above.