Python

A 2-post collection

How to scrape Yahoo Finance and extract fundamental stock market data using Python, LXML, and Pandas

By Matt Button |  Jan 24, 2019  | python, pandas, lxml, scraping, finance, featured

In this blog post I’ll show you how to scrape Income Statement, Balance Sheet, and Cash Flow data for companies from Yahoo Finance using Python, LXML, and Pandas.

I’ll use data from Mainfreight NZ (MFT.NZ) as an example.

The screenshot below shows what you can expect to get by following the steps in this blog post:

The first few columns of a Pandas DataFrame containing MFT.NZ Balance Sheet data

By following the steps in this blog post, you’ll also generate a DataFrame containing data from the Income Statement, and Cash Flow statement.

After creating Pandas DataFrames, I’ll show you how to export everything to an Excel file, so you’ll have output that looks something like this:

Continue Reading...

Google Authentication with Python and Flask

By Matt Button |  Jan 5, 2019  | python, flask, google-authentication, google-api, google-drive, featured

In this blog post, you will learn how to create a Python app using Flask and the Google API which will:

  • Support Google Authentication with Python and Flask
  • Restrict access via an OAuth scope, so that the app can only view and manage Google Drive files and folders which were created by the app
  • Read and write files on the user’s Google Drive with Python.

By the time you get to the end of this blog post, you’ll have built a basic Google Drive file browser which looks something like:

OAuth Google Drive Scope

This blog post is divided up into sections which progressively build up an app which interacts with the user’s Google Drive. If you only want to find out about how to do user Authentication with Google and Python, feel free to stop there.

Continue Reading...