资源简介
linfanrong_10164999.rar
代码片段和文件信息
# coding: utf8
import sys os pickle urllib2
# vincent willem van gogh
# vincent Paul Gauguin willem gogh
ARTIST_PAGE = r‘http://commons.wikimedia.org/wiki/Category:Google_Art_Project_works_by_%s‘
currentPath = os.path.split(os.path.realpath(__file__))[0] + os.sep
artistsFile = currentPath + ‘artist.pk‘
downloadPath = os.sep.join(currentPath.split(os.sep)[0:-2] + [‘download‘]) + os.sep
with open(artistsFile ‘rb‘) as a:
ARTIST_NAMES = pickle.load(a)
def find_artist_pics(artistName):
picDictFile = currentPath + ‘artist_pics.pk‘
with open(picDictFile ‘rb‘) as a:
aPicDict= pickle.load(a)
return aPicDict[artistName]
def format_input_name_list(inName):
return [i for i in inName.upper().replace(‘_‘ ‘ ‘).split(‘ ‘) if len(i)]
def find_artist(fNameList):
counter = {}
for name in ARTIST_NAMES:
sName = name.upper().split(‘_‘)
for i in fNameList:
if i in sName:
if name in counter:
counter[name] += 1
else:
counter[name] = 1
fRange = range(len(fNameList) 0 -1)
res = {}
for num in fRange:
for name in counter:
if num == counter[name]:
if num in res:
res[num].append(name)
else:
res[num] = [name]
return res
def open_url(artistName):
url = ARTIST_PAGE % artistName
print ‘ Opening: %s‘ % url
if sys.platform==‘win32‘:
os.startfile(url)
elif sys.platform==‘darwin‘:
os.system(‘open %s‘ % url)
else:
try:
os.system(‘xdg-open %s‘ % url)
except OSError:
print ‘Please open a browser : ‘ + url
def download_pics(artistName):
# savePath = os.sep.join(currentPath.split(os.sep)[0:-2] + [‘download‘]) + os.sep
# print savePath
dArtistPath = downloadPath + artistName + os.sep
if not os.path.exists(dArtistPath):
os.makedirs(dArtistPath)
print ‘ Downloading %s\‘s works ...‘ % artistName.replace(‘_‘ ‘ ‘)
for source in find_artist_pics(artistName):
picName = source.split(‘/‘)[-1]
target = dArtistPath + picName
if not os.path.exists(target):
print ‘ ‘ + picName
try:
open(target “wb“).write(urllib2.urlopen(source).read())
except:
print ‘error‘
def open_or_download(artistName):
aName = artistName.replace(‘_‘ ‘ ‘)
print ‘ [1] Open %s\‘s page‘ % aName
print ‘ [2] Download %s\‘s works‘ % aName
x = str(raw_input(‘ Select: ‘))
if x == ‘1‘ or not x:
open_url(artistName)
elif x == ‘2‘:
download_pics(artistName)
else:
raise
def select_artist(inName):
fNameList = format_input_name_list(inName)
fArtist = find_artist(fNameList)
nameLen = len(fArtist)
for num in range(nameLen 0 -1):
aList =
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 78 2016-04-18 00:16 google_artist_for_win.bat
文件 182556 2015-07-28 02:01 readme.png
文件 5448129 2017-01-15 22:53 下载教程.jpg
文件 136468 2015-07-13 03:29 bin\artist.pk
文件 2930445 2015-07-27 12:03 bin\artist_pics.pk
文件 4343 2017-12-19 10:34 bin\google_artist.py
文件 10123501 2015-01-05 06:14 bin\py.exe
文件 54 2015-07-13 02:49 google_artist_for_mac.command
目录 0 2017-12-19 20:08 download
目录 0 2017-12-19 20:08 bin
----------- --------- ---------- ----- ----
18825574 10
相关资源
- The.Art.Of.Unit.Testing.With.Examples.in.C.2nd
- myGame.rar
- 带手机版数据同步财税代理公司注册
- pdf课本及习题答案.rar
- 深度学习PDF非扫描版(中文版)麻省
- doudizhu_shffule_src.zip
- 随机信号分析解题指南.pdf
- ios12.3驱动.zip
- 百万邮件系统多机版.rar
- learnopengl-cn-2018年5月更新.pdf
- zw_学习OpenCV(中文版).zip
- 1-300.pdf
- pyqt5windows生成二维工具源码
- KNN疾病预测算法Demo
- ABAQUS单元失效浅析(单元删除
- Jtopo+json格式数据代码
- 解多目标规划的单纯形代码
- TerraVolVoxelTerrainEngine2.1c.7z
- VA_X_Setup2118.rar
- CHS_Ha_PasswarekitEnterprise10.0.exe
- 无线通信AndreaGoldsmith杨鸿文等译.rar
- 迅捷PDF转换器破解版.rar
- 迅捷PDF编辑器破解版.rar
- 金字塔原理1清晰扫描版.pdf
- TeamViewer_11已激活+破解版+随意换ID.z
- FieldtheoryofGuidedwavesCollin__2nd.pdf
- 先进电气驱动的分析建模与控制[比
- IPC-J-STD033潮湿、回流焊敏感表面贴装
- 网络是怎样连接的_户根勤.pdf
- tesseract最新最全资料.rar
评论
共有 条评论