Skip to content

Instantly share code, notes, and snippets.

@dray89
dray89 / Monthly_Oil_Production_Data.py
Last active June 20, 2022 06:15
Social Graphs - Python
#pip install EIA-python
#pip install networkx
import numpy as np
import pandas as pd
import eia
import networkx as nx
import matplotlib.pyplot as plt
#Get API key from EIA website and pass into eia.API() method
apiKey = "5f54b3e66477e22ec068066b1de8026d"
@dray89
dray89 / yahoo_statistics.py
Last active January 18, 2023 00:07
Python Scrape Yahoo Stock Market Statistics Webpage
import pandas as pd
import numpy as np
from bs4 import BeautifulSoup
import requests, lxml
from lxml import html
class statistics:
@dray89
dray89 / Scrapy-tables
Created August 29, 2020 23:52
How to scrape tables using Scrapy
import scrapy
import pandas
from ..items import YahooItem
class YahooSpider(scrapy.Spider):
name = 'Yahoo'
symbols = ["ADSK","BA","CAT","EBAY","GS","HSY","IBM","JPM","WMT","SHOP",
"T", "F", "TRI", "AMZN", "C", "A", "O", "B","MSFT", "NVDA",
"DIS", "AAL", "NFLX", "JNJ","BAC","GOOGL", "WFC"]
start_urls = ['https://finance.yahoo.com/quote/{0}/history?p={0}'.format(x) for x in symbols]
@dray89
dray89 / dividend_history.py
Created May 28, 2020 03:52
Python Web Scraping: Yahoo Finance Stock Dividend History
from datetime import datetime, timedelta
import time, requests, pandas, lxml
from lxml import html
def format_date(date_datetime):
date_timetuple = date_datetime.timetuple()
date_mktime = time.mktime(date_timetuple)
date_int = int(date_mktime)
date_str = str(date_int)
return date_str