googleImageDownload.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:imageDownloader 作者: whcacademy 项目源码 文件源码
def openBrowserRecursively(total, idName, browser):
    try:
        for i in range(total):
            iterator = i * 100
            url = r"https://www.google.com/search?q={word}&newwindow=1&biw=300&bih=629&tbm=isch&ijn={times}&start={start}"
            try:
                browser.get(url.format(word= idName, start=iterator,times = i))
            except SocketError as e:
                if e.errno != errno.ECONNRESET:
                    raise # raise to reset the connection
                pass
        time.sleep(1.5) # 1.5 seconds is the tuned time for HKU service not to be monitored and closed
    except:
        if isWindows:
            os.system("taskkill /im chrome.exe /F")
        else :
            os.system("kill " + str(os.getpid()))
        openBrowserRecursively(total, idName, browser)

# basic session setup
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号