Skip to content

Instantly share code, notes, and snippets.

@benburry
Created January 16, 2014 18:24
Show Gist options
  • Save benburry/8460394 to your computer and use it in GitHub Desktop.
Save benburry/8460394 to your computer and use it in GitHub Desktop.
Try to work out if AirBnB listings still exists from its url
#!/usr/bin/env python
import requests
import sys
import time
import re
PAT = re.compile(r'^https?://(?:w{3}\.)?airbnb\..*/([^/]+)/?$')
def try_airbnb(url, exclude=False):
m = PAT.match(url)
if m:
r = requests.get(url)
if r.status_code == requests.codes.ok and r.url.endswith(m.group(1)):
print url
elif not exclude:
print '~~%s~~' % url
if __name__ == '__main__':
exclude = (len(sys.argv) > 1 and sys.argv[1] == '-e')
try:
for line in sys.stdin:
line = line.strip()
if line:
time.sleep(0.2) # bless
try_airbnb(line, exclude=exclude)
except KeyboardInterrupt:
pass
@benburry
Copy link
Author

cat list_of_airbnb_urls | ./try_airbnb.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment