Skip to content

Instantly share code, notes, and snippets.

@dray89
dray89 / Monthly_Oil_Production_Data.py
Last active Jun 20, 2022
Social Graphs - Python
View Monthly_Oil_Production_Data.py
#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 / Scrapy-tables
Created Aug 29, 2020
How to scrape tables using Scrapy
View Scrapy-tables
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
Python Web Scraping: Yahoo Finance Stock Dividend History
View dividend_history.py
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
@dray89
dray89 / yahoo_statistics.py
Last active Apr 12, 2022
Python Scrape Yahoo Stock Market Statistics Webpage
View yahoo_statistics.py
import pandas as pd
import numpy as np
from bs4 import BeautifulSoup
import requests, lxml
from lxml import html
class statistics: