Created
December 15, 2016 12:02
-
-
Save anirudhramanan/7327ea3c2ef28b23e834e458b5efe2c9 to your computer and use it in GitHub Desktop.
Script to grep all the internal links for a given url.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import argparse | |
import re | |
argparser = argparse.ArgumentParser(add_help=True) | |
argparser.add_argument('url', | |
help='Enter the url, include http/https also') | |
url = argparser.parse_args().url | |
# connect to the specified url | |
webUrl = requests.get(url) | |
# read html | |
htmlData = webUrl.text | |
internalLinks = re.findall('"((http|ftp)s?://.*?)"', htmlData) | |
# output links | |
for link in internalLinks: | |
print(link[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment