Questions tagged [esprima-python]

4 questions
1
vote
0 answers

How do I remove a node in a ast tree using esprima in python?

How can I remove the nodes in a ast tree using esprima? Here is my code: import esprima class MyVisitor(esprima.NodeVisitor): def visit_ExpressionStatement(self, node): return None visitor = MyVisitor() tree =…
JJ Cauton
  • 109
  • 7
1
vote
0 answers

How to replace and insert a new node into a ast tree using esprima for python?

I am having trouble trying to replace and insert a new node into the ast tree using esprima for python. There is an example on github but then it replaces all the nodes with the same node that I created but I just want one of them changed while…
JJ Cauton
  • 109
  • 7
1
vote
0 answers

How to generate all the leaf to leaf path in an AST?

Given a JS snippet, how to generate all the leaf-to-leaf path from the AST? Let’s say the code snippet is: var answer = 6 * 7; Example AST: https://esprima.org/demo/parse.html For this code snippet, I have to generate all the paths from leaf to…
Exploring
  • 2,493
  • 11
  • 56
  • 97
1
vote
1 answer

Python BeautifulSoup how to extract var result from javascript element?

I'm new with Python and I've been trying to use BeautifulSoup to extract one particular data line from a variable defined in a script element. Code: import requests from bs4 import BeautifulSoup import esprima #----------------some comment' URL =…
Shaggy
  • 33
  • 2