Guest User

Untitled

a guest
Apr 22nd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. #!/usr/bin/env python
  2. from urllib2 import urlopen
  3. from sys import argv, exit
  4. from re import findall
  5.  
  6. def main(URL):
  7.   html = urlopen(URL).read()
  8.   links = findall(r'<a href="(\S+)">', html)
  9.   f = open('URLs.txt', 'w')
  10.   for link in links:
  11.     f.write(link + '\n')
  12.  
  13. if __name__ == '__main__':
  14.   if len(argv) == 2:
  15.     main(argv[1])
  16.   else:
  17.     exit('Usage: ./scrape.py URL')
Add Comment
Please, Sign In to add comment