Python3 execute JavaScript script, js2py tutorial

Source: Internet
Author: User


Introduction: Js2py Installation Library Now many Web sites have started to use JS encryption technology, so this library must be learned, or you will not be able to play with the tutorial js2py execute a single statement JS2PY executive function Summary: Now many of the Web site is writing crawlers to use JS encryption technology, so this library must learn ..

Executes the JS code in the JS file



The code in the JS file




function enString(data){
        var key1 = "YHXWWLKJYXGS";
        var key2 = "ZFCHHYXFL10C";
        var key3 = "DES";
        var enchex = key1+key2+key3+data
        return enchex;
}


Python code




import js2py

data=open(‘sjtest.js‘,‘r‘,encoding= ‘utf8‘).read()
print(type(data))
data=js2py.eval_js(data)
print(data(‘1234569‘))
result:


<class ' str ' >
yhxwwlkjyxgszfchhyxfl10cdes1234569

Summary: In order to achieve their own crawler spring and Autumn Dream, I also a resistance to the end.


Python3 execute JavaScript script, js2py tutorial


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.