Visitar URL original
Is there a way to access html elements like document or navigator? · Issue #109 · pyscript/pyscript · GitHub
The Wayback Machine - https://web.archive.org/web/20220504174111/https://github.com/pyscript/pyscript/issues/109
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to access html elements like document or navigator? #109

Open
luptior opened this issue May 2, 2022 · 6 comments
Open

Is there a way to access html elements like document or navigator? #109

luptior opened this issue May 2, 2022 · 6 comments
Labels
good first issue tag: docs

Comments

@luptior
Copy link

@luptior luptior commented May 2, 2022

Trying to move some of the JavaScripts to pyscript, its there a way to of something like this in pyscript now?

var metas = document.getElementsByTagName('meta');

@its-pablo
Copy link

@its-pablo its-pablo commented May 2, 2022

ooh moving through the DOM with this tool will be cool

@taffarel55
Copy link

@taffarel55 taffarel55 commented May 2, 2022

It'd be wonderful!

@luptior luptior changed the title Is there a way to access html elements like document pr navigator? Is there a way to access html elements like document or navigator? May 2, 2022
@cceyda
Copy link

@cceyda cceyda commented May 2, 2022

from js import document, DOMParser, setInterval
saw this line in an example so there seems to be a thing, but would have to dig deeper into code. you can maybe get html from document and use a python DOM parser lib. which maybe a weird way to go about it. uncharted territory, much fun!

@tirthajyoti
Copy link

@tirthajyoti tirthajyoti commented May 2, 2022

I am sort of using a mix of Element class and document class from js. Check out my Pandas demo HTML and look at the pyscript functions at the bottom where I grab a random HTML table generated by NumPy from a div above and read it back using these tricks (like document.getElementbyId) into Pandas to generate simple statistics.

https://tirthajyoti.github.io/pyscript_pandas.html

@cceyda
Copy link

@cceyda cceyda commented May 2, 2022

document.querySelector seems to be a thing already!

element = document.querySelector(f'#{element_id}');

@philippjfr philippjfr added good first issue tag: docs labels May 2, 2022
@philippjfr
Copy link

@philippjfr philippjfr commented May 2, 2022

As mentioned by @cceyda this is possible by importing from the js package. If someone wants to contribute some guidance and clear examples demonstrating DOM manipulation that would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue tag: docs
Projects
None yet
Development

No branches or pull requests

6 participants