- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrabWeb.py
More file actions
Latest commit
30 lines (25 loc) · 664 Bytes
/
Copy pathgrabWeb.py
File metadata and controls
30 lines (25 loc) · 664 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
#!/usr/bin/env python
fromurllibimporturlretrieve
deffirstNonBlank(lines):
foreachLineinlines:
ifnoteachLine.strip():
continue
else:
returneachLine
deffirstLast(webpage):
f=open(webpage)
lines=f.readlines()
f.close()
printfirstnonblank(lines),
lines.reverse()
printfirstnonblank(lines),
defdownload(url='http://www',
process=firstLast):
try:
retval=urlretrieve(url)[0]
exceptIOError:
retval=None
ifretval: # do some processing
process(retval)
if__name__=='__main__':
download()