Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the methods for Python to execute js strings

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains the "Python implementation of js strings what are the methods", the content of the explanation is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "what are the methods of Python execution of js strings"!

Method

It is a little slow to execute large js

Specially coded input or output parameters will report an error, the solution:

You can encode the input or output parameters in base64. Base64 is in English and numbers, and there are no special characters.

1--js2pypip insatll js2py# gets the environment context = js2py.EvalJs () # load executes context.execute ('put JS character code') 2--execjsimport execjsprint (execjs.get () .name) # Node.js (V8) import execjsuser_id = '3232597584'url = f' https://www.toutiao.com/toutiao/api/pc/feed/?min_behot_time=1588149898&category=__all__&utm_source=toutiao&widen=1&tadrequire=true&user_id={ User_id} & visited_uid= {user_id} 'js_index = "js"# Open the js file to read # new_url = execjs.compile (open (" / Users/ts/Desktop/Jeff/ Jinri Toutiao / new_sign.js "). Read ()) .call (' get_sigtrue' Url) # read the js string new_url = execjs.compile (js_index) .call ('get_sigtrue', url) print (new_url) 3--execjsimport execjsdef get_js (): F = open (". / new_sign.js",' r' Encoding = 'UTF-8') line = f.readline () htmlstr =' 'while line: htmlstr = htmlstr + line line = f.readline () return htmlstrjsstr = get_js () ctx = execjs.compile (jsstr) user_id =' 3232597584'url = f 'https://www.toutiao.com/toutiao/api/pc/feed/?min_behot_time=1588149898&category=__all__&utm_source=toutiao&widen=1&tadrequire=true&user_id={ User_id} & visited_uid= {user_id} 'print (ctx.call (' getUrl') Url) Thank you for your reading The above is the content of "what are the methods for Python to execute js strings?" after the study of this article, I believe you have a deeper understanding of the method of executing js strings in Python, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report