GeezerVison is showing github.com — after modification. mp3 and docs can be installed in home directory · Xu-Guo/python@f628b0a
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: spider/downloadFile.py +5-2Lines changed: 5 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
5 | 5 | import urllib2 |
6 | 6 | import time |
7 | 7 | import os |
| 8 | +from os.path import expanduser |
8 | 9 | import sys |
9 | 10 |
|
10 | 11 |
|
11 | 12 | class DownloadFile(object): |
12 | 13 |
|
| 14 | + home = expanduser("~") |
13 | 15 | subfolder = time.strftime('%Y%m%d') + "download/" |
14 | 16 |
|
15 | | - def __init__(self, filename, url, based='~/Music/'): |
16 | | - self.dictionary = based + DownloadFile.subfolder |
| 17 | + def __init__(self, filename, url, based='/Music/'): |
| 18 | + self.dictionary = DownloadFile.home + based + DownloadFile.subfolder |
| 19 | + # self.dictionary = based + DownloadFile.subfolder |
17 | 20 | # if directory does not exist, create a new one |
18 | 21 | if(not os.path.exists(self.dictionary)): |
19 | 22 | os.makedirs(self.dictionary, 0755) |
|
Collapse file
Copy file name to clipboard Collapse file
Copy file name to clipboardExpand all lines: spider/science60Contents.py +4-2Lines changed: 4 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
8 | 8 | import time |
9 | 9 | import os |
10 | 10 | from bs4 import BeautifulSoup |
| 11 | +from os.path import expanduser |
11 | 12 | import re |
12 | 13 |
|
13 | 14 |
|
14 | 15 | class Content(object): |
15 | 16 |
|
16 | 17 | subfolder = "doc_" + time.strftime('%Y%m%d') + "download/" |
| 18 | + home = expanduser("~") |
17 | 19 | """docstring for content""" |
18 | 20 |
|
19 | | - def __init__(self, filename='default.txt', url='', based='~/Music/'): |
| 21 | + def __init__(self, filename='default.txt', url='', based='/Music/'): |
20 | 22 | self.url = url |
21 | 23 | self.user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' |
22 | 24 | self.headers = {'User-Agent': self.user_agent} |
23 | | - self.dictionary = based + Content.subfolder |
| 25 | + self.dictionary = Content.home + based + Content.subfolder |
24 | 26 |
|
25 | 27 | # if directory does not exist, create a new one |
26 | 28 | if(not os.path.exists(self.dictionary)): |
|
Collapse file
Copy file name to clipboard