Skip to content

Instantly share code, notes, and snippets.

@scrapehero
scrapehero / yelp.py
Last active December 18, 2021 13:28
Python 2 code to extract business listings from Yelp.com
from lxml import html
import unicodecsv as csv
import requests
from time import sleep
import re
import argparse
import json
def parse(url):
@scrapehero
scrapehero / yahoo_finance.py
Last active August 24, 2021 19:04
Python 2 code to extract stock market data from Yahoo Finance
from lxml import html
import requests
from exceptions import ValueError
from time import sleep
import json
import argparse
from collections import OrderedDict
from time import sleep
def parse(ticker):
@scrapehero
scrapehero / expedia.py
Last active May 17, 2019 14:35
Python 2 code to extract flight details from expedia.com
import json
import requests
from lxml import html
from collections import OrderedDict
import argparse
def parse(source,destination,date):
for i in range(5):
try:
url = "https://www.expedia.com/Flights-Search?trip=oneway&leg1=from:{0},to:{1},departure:{2}TANYT&passengers=adults:1,children:0,seniors:0,infantinlap:Y&options=cabinclass%3Aeconomy&mode=search&origref=www.expedia.com".format(source,destination,date)
@scrapehero
scrapehero / target.py
Last active April 5, 2023 15:33
Python 3 code to extract target store locations
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
import re
from time import time
import json
import argparse
def get_store(store):
store_name = store['Name']
@scrapehero
scrapehero / ebay.py
Created February 12, 2018 08:02
Python 2 code to extract product details from ebay
from lxml import html
import requests
from pprint import pprint
import unicodecsv as csv
from traceback import format_exc
import argparse
def parse(brand):
for i in range(5):
try:
@scrapehero
scrapehero / zillow.py
Created February 12, 2018 07:57
Python 2 code to extract real estate listings from zillow.com
from lxml import html
import requests
import unicodecsv as csv
from exceptions import ValueError
import argparse
def parse(zipcode,filter=None):
if filter=="newest":
url = "https://www.zillow.com/homes/for_sale/{0}/0_singlestory/days_sort".format(zipcode)
@scrapehero
scrapehero / fandango.py
Created February 12, 2018 07:46
Python 3 Code for scraping movie details from fandango.com
from lxml import html, etree
import datetime
import requests
import re
import os
import sys
import unicodecsv as csv
import argparse
import json
# from exceptions import ValueError
@scrapehero
scrapehero / yelp_search.py
Created February 5, 2018 07:20
Python 3 code to extract business details from Yelp.com
from lxml import html
import csv
import requests
#from exceptions import ValueError
from time import sleep
import re
import argparse
def parse(url):
headers = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36'}
@scrapehero
scrapehero / nasdaq_finance.py
Last active July 3, 2022 06:38
Script to scrape financial data from NASDAQ
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from lxml import html
import requests
from time import sleep
import json
import argparse
from random import randint
@scrapehero
scrapehero / fandango.py
Last active February 12, 2018 07:48
Python 2 code to extract movie details from fandango.com
from lxml import html, etree
import datetime
import requests
import re
import os
import sys
import unicodecsv as csv
import argparse
import json
from exceptions import ValueError