-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwords.py
More file actions
52 lines (39 loc) · 973 Bytes
/
Copy pathwords.py
File metadata and controls
52 lines (39 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Sat May 19 12:39:39 2018
@author: Ankit
"""
"""
This module is used to fetch data from provided URL.
Usage: python words.py 'http://sixty-north.com/c/t.txt'
"""
import sys
from urllib2 import urlopen
def fetchFromUrl(url):
"""
Fetch the data from the provided URL
input: URL
output: list of data fetched from URL
"""
#'http://sixty-north.com/c/t.txt'
story = urlopen(url)
story_words = []
for line in story:
for words in line.split():
story_words.append(words)
return story_words
def printItems(items):
"""
Print the items
input: list of items
output: prints each item in list
"""
for item in items:
print item
def main(url):
Item = fetchFromUrl(url)
printItems(Item)
if __name__== "__main__":
url = sys.argv[1] # first argument will be file name
main(url)