forked from rty813/doc_downloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocDownloader.py
69 lines (60 loc) · 1.81 KB
/
docDownloader.py
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import fire
import pymysql
import os
conn = None
def insertDB(url):
cursor = conn.cursor()
sql = f"INSERT INTO history(url) VALUES ('{url}');"
cursor.execute(sql)
conn.commit()
cursor.close()
def main():
global conn
conn = pymysql.connect("orca-tech.cn", "root", "orcatech", "doc_download")
if not os.path.exists('./temp'):
os.mkdir('./temp')
if not os.path.exists('./output'):
os.mkdir('./output')
while True:
url = input("请输入网址(输入exit退出):")
if 'doc88' in url:
# 道客巴巴
import doc88
doc88.download(url)
elif 'book118' in url:
# 原创力
from book118 import Book118
from bs4 import BeautifulSoup
import urllib
html = BeautifulSoup(urllib.request.urlopen(
url).read(), features='lxml')
title = html.title.string[:-4]
Book118(url.split('/')[-1].split('.')[0], title).getPDF()
elif 'taodocs' in url:
# 淘豆网
import taodocs
taodocs.download(url)
elif 'docin' in url:
# 豆丁
# http://211.147.220.164/index.jsp?file=96519470&width=800&pageno=1
import douding
douding.download(url)
# elif 'jinchutou' in url:
# # 金锄头
# import jinchutou
# jinchutou.download(url)
elif 'ishare' in url:
import ishare
ishare.download(url)
elif 'exit' in url:
conn.close()
break
else:
print('暂不支持')
try:
insertDB(url)
except Exception:
pass
if __name__ == "__main__":
fire.Fire(main)
# "https://www.doc88.com/p-6099938057537.html"