Skip to content

Instantly share code, notes, and snippets.

dray89 /
Last active Jun 20, 2022
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 / 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 = ['{0}/history?p={0}'.format(x) for x in symbols]
dray89 /
Created May 28, 2020
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
dray89 /
Last active Apr 12, 2022
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: