How to do it

We proceed with the recipe as follows:

  1. In the 10/04 folder is an api.py file that implements a modified Flask-RESTful API from earlier, but with several  modifications. Let's examine the code of the API:
from flask import Flaskfrom flask_restful import Resource, Apifrom elasticsearch import Elasticsearchfrom nameko.standalone.rpc import ClusterRpcProxyapp = Flask(__name__)api = Api(app)CONFIG = {'AMQP_URI': "amqp://guest:guest@rabbitmq"}class JobListing(Resource):    def get(self, job_listing_id):        print("Request for job listing with id: " + job_listing_id)        es = Elasticsearch(hosts=["elastic"])        if (es.exists(index='joblistings', doc_type='job-listing', id=job_listing_id)):            print('Found the document in Elasticsearch') doc = es.get( ...

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.