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

Cannot access specific tab text/html contents #72

Open
philipsd6 opened this issue Jun 2, 2022 · 0 comments
Open

Cannot access specific tab text/html contents #72

philipsd6 opened this issue Jun 2, 2022 · 0 comments

Comments

@philipsd6
Copy link

I'd like to be able to retrieve the HTML/text from a specific tab, however, it seems it's only possible to call get_html() to get the HTML for all the /active/ tabs. I would like to be able to loop through tabs of interest and activate them unfocused so they load the HTML, and then be able to retrieve just that HTML. I have > 600 tabs open, so it's unreasonable to try to activate all of them so I can get all the HTML and then get the ones I want.

Conceptually what I want to do is this:

tabs = client.list_tabs()
my_tabs = [Tab(tab) for tab in tabs if "such and such" in tab]
for tab in my_tabs:
    client.activate_tab(tab.id, focused=False)  # ensure the tab has HTML loaded
    contents = client.get_html(tab.id)
    do_something(tab, contents)
    client.close_tab(tab.id)  # or unload -- I wish we could! I'll make a feature request!

All I can do now though is process the current results of get_html() and then close those tabs, refresh and start over.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant