Esempio n. 1
0
def _get_path(username):
    path = {
        'Windows': pkgUtils.getLevelPath(-2, '/download/lofter/' + username),
        'Linux': pkgUtils.getLevelPath(-2, '/download/lofter/' + username)
    }.get(platform.system())
    if not os.path.isdir(path):
        os.makedirs(path)
    return path
Esempio n. 2
0
def savePictures(itemPagesurl, albumName):
    global pages
    header = {
        "User-Agent": getUserAgent(1),
        "Connection": "keep-alive",
        "Referer": "image / webp, image / *, * / *;q = 0.8",
        "Accept": "image/webp,image/*,*/*;q=0.8"
    }
    try:
        htmlPath = getHtml(itemPagesurl, header, 10)
        print(itemPagesurl)  # http://www.zngirls.com/g/27439/6.html
        pages = htmlPath.xpath('//div[@class="gallery_wrapper"]/ul/img/@src')
        names = htmlPath.xpath('//div[@class="gallery_wrapper"]/ul/img/@alt')
    except Exception as error:
        print("savePictures album parse Exception:")
    for i in range(len(pages)):
        print(pages[i])  # https://t1.onvshen.com:85/gallery/22784/27439/s/015.jpg
        try:
            headers = {
                "User-Agent": getUserAgent(1),
                "Connection": "keep-alive",
                "Referer": pages[i]
            }
            respHtml = getHtmlData(pages[i], headers, 10)
            cPath = getLevelPath(-2, '\\download\\meinv\\' + albumName + "\\")
            imgPath = '%s.jpg' % (cPath + names[i])
            if os.path.isfile(imgPath):
                pass
            else:
                binFile = open(imgPath, "wb")
                binFile.write(respHtml);
                binFile.close();
        except Exception as error:
            print("savePictures pic fetch Exception:")
Esempio n. 3
0
def spiderPic(html, keyword):
    cPath = getLevelPath(-2, '\\download\\baidu\\' + keyword + "\\")
    print(cPath)
    print('正在查找 ' + keyword + ' 对应的图片,下载中,请稍后......')
    pattern = '"objURL":"(.*?)"'
    saveUtils.save_img(html, pattern, cPath)