How to do it

We proceed with the recipe as follows:

  1. The code for the microservice is straightforward. The code for it is in 10/02/call_scraper_microservice.py and is shown here:
from nameko.rpc import rpcimport sojobs.scraping class ScrapeStackOverflowJobListingsMicroService:    name = "stack_overflow_job_listings_scraping_microservice"    @rpc    def get_job_listing_info(self, job_listing_id):        listing = sojobs.scraping.get_job_listing_info(job_listing_id)        print(listing)        return listingif __name__ == "__main__":    print(ScrapeStackOverflowJobListingsMicroService("122517"))
  1. We have created a class to implement the microservice and given it a single method, get_job_listing_info.  This method simply wraps the implementation in the sojobs.scraping module, ...

Get Python Web Scraping Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.