Added error handling and more efficient regexp for url scraping.