Skip to content

Instantly share code, notes, and snippets.

@scrapehero
scrapehero / zillow.py
Last active December 13, 2023 16:05
Python 3 script to find real estate listings of properties up for sale on zillow.com
from lxml import html
import requests
import unicodecsv as csv
import argparse
import json
def clean(text):
if text:
return ' '.join(' '.join(text).split())
@scrapehero
scrapehero / yelp_search.py
Last active April 7, 2022 18:31
Python 3 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 / zillow.py
Created May 9, 2017 15:00
Python script to find real estate listings of properties up for sale on 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)
from lxml import html
import csv
import os
import requests
from exceptions import ValueError
from time import sleep
from random import randint
def parse(url):
headers = {
@scrapehero
scrapehero / yelp_reviews_parser.py
Last active February 9, 2018 08:11
Python 3 code to extract business details from a restaurant on Yelp.com
from lxml import html
import unicodecsv as csv
import requests
# from exceptions import ValueError
from time import sleep
import re,urllib
import argparse
import traceback
def parse(url):
from lxml import html
import json
import requests
from exceptions import ValueError
from time import sleep
import re,urllib
import argparse
def parse(url):
# url = "https://www.yelp.com/biz/frances-san-francisco"
@scrapehero
scrapehero / amazon_reviews.py
Last active December 11, 2019 16:09
Python Code to Scrape Customer Reviews from Amazon.com. Read more on https://www.scrapehero.com/how-to-scrape-amazon-product-reviews-using-python/
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Written as part of https://www.scrapehero.com/how-to-scrape-amazon-product-reviews-using-python/
from lxml import html
import json
import requests
import json,re
from dateutil import parser as dateparser
from time import sleep
import requests
import json
import unicodecsv as csv
import argparse
from argparse import RawTextHelpFormatter
def parse(location,sort):
print "Retrieving Location Details"
location_details_url = "https://www.viator.com/ajaxSegmentSearch.jspa?term=%s"%(location)
location_response = requests.get(location_details_url).text
@scrapehero
scrapehero / tripadvisor_scraper_hotel.py
Last active December 17, 2018 10:09
Python 2.7 code to extract data from tripadvisor hotel
# -*- coding: utf-8 -*-
from lxml import html
import requests
from collections import OrderedDict
import json
import argparse
import re
import sys
# Adjust MAX_RETRY according to the blocking from tripadvisor
MAX_RETRY = 10
@scrapehero
scrapehero / tripadvisor_scraper.py
Last active January 24, 2021 15:06
Python Script to scrape Tripadvisor.com for Hotels in a locality. Code Written as part of https://www.scrapehero.com/how-to-scrape-tripadvisor/
#!/usr/bin/env python
from datetime import datetime
from time import time
from lxml import html,etree
import requests,re
import os,sys
import unicodecsv as csv
import argparse
def parse(locality,checkin_date,checkout_date,sort):