Skip to content

A stock market web scraper that outputs stock price data to a csv file. Built using Go and Colly.

License

Notifications You must be signed in to change notification settings

shosukenoma/stock-price-scraper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scraping stock prices using Go and Colly

Overview

This Go project performs the following tasks:

  • Takes in a list of company ticker symbols (e.g. AMZN for Amazon.com, Inc.)
  • Sends HTTP requests to retrieve HTML from target web pages
  • Extracts data on stock prices by specifying HTML elements
  • Writes out the retrieved data to a .csv file

Install

To run this project, you will need to install Go
Once you have Go installed on your local machine, run the following commands in the terminal:

git clone https://github.com/shosukenoma/stock-price-scraper.git
go get -u github.com/gocolly/colly/...

Usage

Run the following command in the terminal:

go run main.go

Once the program finishes running, you will see a stocks.csv file generated in the same directory.
Screenshot of the new .csv being created

Acknowledgements

This project is inspired by Web Scraping in Golang: Complete Guide 2023
This tutorial article walks us through how to scrape a mock e-commerce website that consists of a well-structured HTML.

Other Resources

Web Scraping for Stock Prices in Python
This article is helpful in getting a general sense of the project structure.

Building a web scraper in Go with Colly
This article accurately shows that c.Visit() should come after all of the callback functions, not before.

Programming in Go for Web Scraping
This article is helpful in understanding how to retrieve data from HTML elements in varying cases not mentioned in the Colly documentation.

Introduction to bufio package in Golang
This article is helpful in understanding the bufio package and the role of defer writer.Flush().

Banner Image
COPYRIGHT (C) 2021 BIDAALA STUDIO/SHUTTERSTOCK

About

A stock market web scraper that outputs stock price data to a csv file. Built using Go and Colly.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages