Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion libearth/crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import collections
import logging
import sys
from contextlib import closing

try:
import urllib.request as urllib2
Expand All @@ -24,7 +25,17 @@
from .version import VERSION


__all__ = 'CrawlError', 'CrawlResult', 'crawl', 'get_feed'
__all__ = ('CrawlError', 'CrawlResult', 'check_reachable_url', 'crawl',
'get_feed')


def check_reachable_url(url):
try:
with closing(open_url(url)) as fp:
fp.read()
return True
except:
return False


def open_url(url):
Expand Down