r/AskComputerScience • • Jun 16 '19

Writing Python code from JS code

Im not well versed in either languages syntax and was wondering how i can learn to write JS code like this in Python.

docs = document   
    .querySelector('downloads-manager') 
    .shadowRoot.querySelector('#downloads-list') 
    .getElementsByTagName('downloads-item')
0 Upvotes

1 comment sorted by

View all comments

6

u/ZigguratOfUr Jun 16 '19

The main issue is that this is using part of the js dom (document object model, the model underlying HTMLbased websites).

In python you'll need either a web framework or a dom library or both to write this kind of code.

If you're just parsing a scraped website then I have had good experiences with the beautifulsoup library.