How bow, scrape, and nod work together
developThe polite package follows a "bow and scrape" workflow to ensure responsible web harvesting etiquette. The workflow is built on three pillars: seeking permission, taking slowly and never asking twice.
bow(): Used to introduce the client to the host. It inquires against the host'srobots.txtfile to ask for permission to scrape. This establishes apolite session.scrape(): The main function used to retrieve data from the remote server using the established session. It automatically handles rate limiting and respects the rules negotiated during thebowstep.nod(): Used to adjust the session's URL. If you need to move to a new path,nodupdates the session's URL while ensuring the new location is also negotiated againstrobots.txt. Once a connection is established viabow, you do not need tobowagain for the same host, onlynodto change paths.
Behind the scenes, polite manages robots.txt caching, user agent strings, rate limiting, and response caching.
session <- bow("https://example.com")
# Use the session to scrape
result <- scrape(session)
# Move to a new path within the same host
session <- nod(session, "https://example.com/new-path")
result <- scrape(session)