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

Add a way to fork a browser #418

Open
DeflateAwning opened this issue May 8, 2023 · 3 comments
Open

Add a way to fork a browser #418

DeflateAwning opened this issue May 8, 2023 · 3 comments

Comments

@DeflateAwning
Copy link

I want a way to fork a Browser state, by calling something like browser_copy = browser.copy(), and then being able to work from browser_copy, while eventually going back to the un-touched browser.

Why I want it

I was writing a scraper for a file browser site. To download files, you first navigate to a specific folder, then you click on each file. I wanted to fork/copy the browser before clicking on each file download link, but couldn't.

What I tried

import copy
browser_copy = copy.copy(browser) # works on the first use, but not after
browser_copy = deepcopy.copy(browser) # crashes here, as it can't copy recursive elements

What I want

I want you to add a browser.copy() or browser.fork() method, which returns a fork of the browser with the same active page, same selected from, same session, etc., which can then be navigated independently from there. This would be similar to duplicating a tab in a GUI web browser, presumably.

@hemberger
Copy link
Contributor

Hi, thanks for the detailed feature request! If you're just looking to retain the current state when you click on a download link, perhaps take a look at StatefulBrowser.download_link. This method doesn't change the browser state. Would this work for you?

@DeflateAwning
Copy link
Author

Great suggestion. I ultimately did go with something similar to that. The issue was that, from the folder listing page, you had to click on each file, and only then was a download link revealed. Using download_link doesn't give you the full link listing functionality, etc., which is why I think this is a useful feature.

@hemberger
Copy link
Contributor

Ah, I see, thanks for the clarification. Yes, in that case a back button or a state cloning method could be helpful.

As a workaround for now, you might be able collect all the links from the main page, and then in a loop visit each subpage to get the download links. (Though it sounds like you might already be doing something like this.)

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

No branches or pull requests

2 participants