Skip to main content

Python crawler reports an error when executing js code: AttributeError: 'NoneType' object has no attribute 'replace'

Recently, I encountered a problem while learning python crawler js reverse engineering.

error code:

UnicodeDecodeError: 'gbk' codec can't decode byte 0xac in position 36: illegal multibyte sequence AttributeError: 'NoneType' object has no attribute 'replace'

The python code statements are as follows:

ctx = execjs.compile(jscode).call('s', encrypt_data)
print(ctx)

Solution:

According to the error message, find the D:\python\Lib\subprocess.py file, click to open it

and then find the corresponding location in the file. Change the encoding=None to encoding='utf-8'.

Finally, re-run the py file and found that no errors were reported.