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

feat(cl_back_scrape_opinions): add optional wait argument #4565

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions cl/scrapers/management/commands/cl_back_scrape_opinions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import time

from juriscraper import AbstractSite
from juriscraper.AbstractSite import logger
from juriscraper.lib.importer import site_yielder
Expand All @@ -20,6 +22,13 @@ def add_arguments(self, parser):
dest="backscrape_end",
help="End value for backscraper iterable creation.",
)
parser.add_argument(
"--backscrape-wait",
type=int,
default=0,
help="Seconds to wait after consuming each element "
"of the backscrape iterable",
)

def parse_and_scrape_site(
self,
Expand Down Expand Up @@ -50,5 +59,12 @@ def parse_and_scrape_site(
site.parse()
self.scrape_court(site, full_crawl=True)

if wait := options["backscrape_wait"]:
logger.info(
"Sleeping for %s seconds before continuing backscrape",
wait,
)
time.sleep(wait)

def save_everything(self, items, index=False, backscrape=True):
super().save_everything(items, index, backscrape)
Loading