If you are a Python administrator or developer interested in interacting with web APIs and have a passion for creating your own web applications, this is the book for you. Basic knowledge of Python programming, APIs, and web services will be an advantage.
Cover Copyright Credits About the Authors Acknowledgments About the Reviewers www.PacktPub.com Table of Contents Preface Chapter 1: Interacting with the Web Using Requests Introduction to HTTP request Python modules Requests versus urllib2 Essence of Requests Making a simple request Response content Different types of request contents Custom headers Sending form-encoded data Posting multipart encoded files Looking up built-in response status codes Viewing response headers Accessing cookies with Requests Tracking redirection of the request using request history Using timeout to keep productive usage in check Errors and exceptions Summary Chapter 2: Digging Deep into Requests Persisting parameters across Requests using Session objects Revealing the structure of a request and response Using prepared Requests Verifying an SSL certificate with Requests Body Content Workflow The Keep-alive facility Streaming uploads Using generator for sending chunk encoded Requests Getting the request method arguments with event hooks Iterating over streaming APIs Encodings HTTP verbs Self-describing the APIs with link headers Transport Adapter Summary Chapter 3: Authenticating with Requests Basic authentication Using basic authentication with Requests Digest authentication Using Digest authentication with Requests Kerberos authentication Using Kerberos authentication with Requests OAuth authentication OAuth 1.0 Using OAuth 1.0 authentication with Requests OAuth 2.0 Custom authentication Summary Chapter 4: Mocking HTTP Requests Using HTTPretty Understanding HTTPretty Installing HTTPretty Working with HTTPretty Setting headers Working with responses Rotating responses. Streaming responses Dynamic responses through callbacks Summary Chapter 5: Interacting with Social Media Using Requests API introduction Getting started with the Twitter API Obtaining an API Key Creating an authentication Request Getting your favorite tweet Performing a simple search Accessing the list of followers Retweets Accessing available trends Updating user status Interacting with Facebook Getting started with the Facebook API Obtaining a key Getting a user profile Retrieving a friends list Retrieving feed Retrieving albums Interacting with reddit Getting started with the reddit API Registering a new account Modifying account information Performing a simple search Searching subreddits Summary Chapter 6: Web Scraping with Python Requests and BeautifulSoup Types of data Structured data Unstructured data Semistructured data What is web scraping? Dos and don'ts of web scraping Predominant steps to perform web scraping Key web scraping tasks What is BeautifulSoup? Document parsers Installation Objects in BeautifulSoup Tags BeautifulSoup NavigableString Comments Web scraping tasks related to BeautifulSoup Searching the tree Navigating within the tree Modifying the Tree Building a web scraping bot - a practical example The web scraping bot Identifying the URL or URLs Using an HTTP client Discovering the pieces of data to scrape Utilizing a web scraping tool Drawing the desired data Summary Chapter 7: Implementing a Web Application with Python Using Flask What is Flask? Getting started with Flask Installing Flask Installing required packages with pip Survey - a simple voting application using Flask Basic file structures Building the application. Writing models with Flask-SQLAlchemy Defining a model Creating a database instance Creating survey models Creating tables in the database Querying database models Views List of all questions New survey Creating a new survey Displaying a survey Updating a survey Deleting a survey New vote form to caste a vote in a survey Casting a vote to a particular choice in a survey Templates The base template The list of questions template Creating a new survey template Showing the details of a survey template Casting a vote template Running the survey application Writing unit tests to survey applications Summary Index.
Description based on publisher supplied metadata and other sources.
Electronic reproduction. Ann Arbor, Michigan : ProQuest Ebook Central, 2021. Available via World Wide Web. Access may be limited to ProQuest Ebook Central affiliated libraries.