Skip to content

Commit

Permalink
add authorization
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewKorzh committed Aug 7, 2024
1 parent 3e92440 commit bae927d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
33 changes: 33 additions & 0 deletions scrapypuppeteer/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,39 @@ def payload(self):
"navigationOptions": self.navigation_options,
"waitOptions": self.wait_options,
}


class Authorization(PuppeteerServiceAction):

endpoint = "authorization"

def __init__(
self, login_selector: str,
password_selector: str,
submit_button_selector: str,
login: str,
password: str,
entry_wait_options: dict = None,
wait_options: dict = None
):
self.login_selector = login_selector
self.password_selector = password_selector
self.login = login
self.password = password
self.submit_button_selector = submit_button_selector
self.entry_wait_options = entry_wait_options
self.wait_options = wait_options

def payload(self):
return {
"loginSelector": self.login_selector,
"passwordSelector": self.password_selector,
"submitButtonSelector": self.submit_button_selector,
"login": self.login,
"password": self.password,
"entryWaitOptions": self.entry_wait_options,
"waitOptions": self.wait_options,
}


class GoForward(PuppeteerServiceAction):
Expand Down
3 changes: 2 additions & 1 deletion scrapypuppeteer/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
Screenshot,
Scroll,
CustomJsAction,
Authorization
)
from scrapypuppeteer.response import (
PuppeteerResponse,
Expand Down Expand Up @@ -228,7 +229,7 @@ def _form_response(

@staticmethod
def _get_response_class(request_action):
if isinstance(request_action, (GoTo, GoForward, GoBack, Click, Scroll)):
if isinstance(request_action, (GoTo, GoForward, GoBack, Click, Scroll, Authorization)):
return PuppeteerHtmlResponse
if isinstance(request_action, Screenshot):
return PuppeteerScreenshotResponse
Expand Down

0 comments on commit bae927d

Please sign in to comment.