Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewKorzh committed Aug 5, 2024
1 parent 736016c commit 1f1bfba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
19 changes: 5 additions & 14 deletions scrapypuppeteer/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,19 @@ class GoTo(PuppeteerServiceAction):
endpoint = "goto"

def __init__(
self, url: str, navigation_options: dict = None, wait_options: dict = None
self, url: str, navigation_options: dict = None, wait_options: dict = None, har_recording: bool = False
):
self.url = url
self.navigation_options = navigation_options
self.wait_options = wait_options
self.har_recording = har_recording

def payload(self):
return {
"url": self.url,
"navigationOptions": self.navigation_options,
"waitOptions": self.wait_options,
"harRecording": self.har_recording,
}


Expand Down Expand Up @@ -224,22 +226,11 @@ def payload(self):


class Har(PuppeteerServiceAction):

"""
receive har data
Takes only one option {"har_state" : "stop"}
To start: cookies = {"har":"start"} in PuppeteerRequest
"""
endpoint = "har"

def __init__(self, options: dict = None):
self.options = options

def payload(self):
return {
"options": self.options,
}
return {}



class RecaptchaSolver(PuppeteerServiceAction):
Expand Down
3 changes: 2 additions & 1 deletion scrapypuppeteer/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def __init__(
page_id: str = None,
close_page: bool = True,
include_headers: Union[bool, List[str]] = None,
har_recording: bool = False,
**kwargs,
):
"""
Expand All @@ -80,7 +81,7 @@ def __init__(
navigation_options = kwargs.pop("navigation_options", None)
wait_options = kwargs.pop("wait_options", None)
action = GoTo(
url, navigation_options=navigation_options, wait_options=wait_options
url, navigation_options=navigation_options, wait_options=wait_options, har_recording = har_recording
)
elif isinstance(action, GoTo):
url = action.url
Expand Down

0 comments on commit 1f1bfba

Please sign in to comment.