Skip to content

Commit

Permalink
Now logging level is warning
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewZMSU committed Jul 1, 2024
1 parent e7d4544 commit 63d2230
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions examples/spiders/auto_recaptcha.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import scrapy
import base64
from twisted.python.failure import Failure
Expand Down Expand Up @@ -47,12 +48,13 @@ def parse_html(self, response: PuppeteerResponse, **kwargs):
action, callback=self.make_screenshot, errback=self.error, close_page=True
)

def make_screenshot(self, response: PuppeteerScreenshotResponse, **kwargs):
@staticmethod
def make_screenshot(response: PuppeteerScreenshotResponse, **kwargs):
data = (
response.screenshot
) # Note that data is string containing bytes, don't forget to decode them!
with open("imageToSave.png", "wb") as fh:
fh.write(base64.b64decode(data))

def error(self, failure: Failure):
self.log("We are in error function!")
self.log("We are in error function!", level=logging.WARNING)
6 changes: 4 additions & 2 deletions examples/spiders/manual_recaptcha.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import scrapy
import base64
from twisted.python.failure import Failure
Expand Down Expand Up @@ -52,12 +53,13 @@ def parse_html(self, response: PuppeteerResponse, **kwargs):
action, callback=self.make_screenshot, errback=self.error, close_page=True
)

def make_screenshot(self, response: PuppeteerScreenshotResponse, **kwargs):
@staticmethod
def make_screenshot(response: PuppeteerScreenshotResponse, **kwargs):
data = (
response.screenshot
) # Note that data is string containing bytes, don't forget to decode them!
with open("imageToSave.png", "wb") as fh:
fh.write(base64.b64decode(data))

def error(self, failure: Failure):
self.log("We are in error function!")
self.log("We are in error function!", level=logging.WARNING)

0 comments on commit 63d2230

Please sign in to comment.