Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- nytimes_com = '''
- This New Liquid Is Magnetic, and Mesmerizing
- Scientists have created “soft” magnets that can flow
- and change shape, and that could be a boon to medicine
- and robotics. (Source: New York Times)
- Most Wikipedia Profiles Are of Men. This Scientist Is Changing That.
- Jessica Wade has added nearly 700 Wikipedia biographies for
- important female and minority scientists in less than two
- years.
- '''
- bloomberg_com = '''
- The Space Race: From Apollo 11 to Elon Musk
- It's 50 years since the world was gripped by historic images
- of Apollo 11, and Neil Armstrong -- the first man to walk
- on the moon. It was the height of the Cold War, and the charts
- were filled with David Bowie's Space Oddity, and Creedence's
- Bad Moon Rising. The world is a very different place than
- it was 5 decades ago. But how has the space race changed since
- the summer of '69? (Source: Bloomberg)
- Twitter CEO Jack Dorsey Gives Talk at Apple Headquarters
- Twitter and Square Chief Executive Officer Jack Dorsey
- addressed Apple Inc. employees at the iPhone maker’s headquarters
- Tuesday, a signal of the strong ties between the Silicon Valley giants.
- '''
- # write your code here
- import os
- while True:
- address = input()
- if address == "exit":
- break
- elif "." not in address:
- print("Error: Incorrect URL")
- continue
- elif address == "exit":
- break
- elif address == "bloomberg.com":
- content = bloomberg_com
- elif address == "nytimes.com":
- content = nytimes_com
- print(content)
- directory = input()
- try:
- os.mkdir(directory)
- print("Directory ", directory, " Created")
- except FileExistsError:
- print("Directory ", directory, "already exists")
- file_name = address[:address.rfind('.')]
- print("имя файла " + file_name)
- fh = open(directory + r"/" + file_name, "a")
- fh.write(content)
- fh.close()
- print("сохранили в файл " + directory + r"/" + file_name)
- try:
- open_file = input()
- handle = open(directory + r"/" + open_file, "r")
- data = handle.read()
- print(data)
- handle.close()
- except FileNotFoundError:
- print("Error, no file")
Advertisement
Add Comment
Please, Sign In to add comment