Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. import requests
  2.  
  3. def check_last_file(text):
  4.     if text[:2] = 'We':
  5.         return True
  6.     else:
  7.         return False
  8.    
  9. def get_url_from_file(file):
  10.     with open(file) as f:
  11.         name = f.readline().strip('\n')
  12.     return name
  13.  
  14. def go_through_chain(url):
  15.     print('I\'m going go to url: %s' % url)
  16.     query = request.get(url)
  17.     content = query.text
  18.     if not check_last_file(content):
  19.         go_through_chain(content)
  20.     else:
  21.         print('URL %s - is FINAL!!!' % content)
  22.  
  23.  
  24. if __name__ == '__main__':
  25.     address = 'https://stepic.org/media/attachments/course67/3.6.3/'
  26.  
  27.     first_step_file = str(input('Enter first file name: '))
  28.     url = address + get_url_from_file(first_step_file)
  29.     go_through_chain(url)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement