예제 #1
0
def spider_url_chrome_by_https2(url):
    browser = None
    display = None
    try:
        display = Display(visible=0, size=(800, 600))
        display.start()

        proxy = 'mimvp-user:[email protected]:53681'
        proxy_zip = get_chrome_proxy_extension(proxy)  # 打包代理zip文件

        chrome_options = Options()  # ok
        chrome_options = webdriver.ChromeOptions()  # ok
        chrome_options.add_extension(proxy_zip)

        chromedriver = os.path.join(os.path.abspath('..'), 'Drivers',
                                    'chromedriver')
        browser = webdriver.Chrome(
            executable_path=chromedriver,
            chrome_options=chrome_options)  # 打开 Chrome 浏览器
        browser.get(url)
        time.sleep(20)
        content = browser.page_source
        print("content: " + str(content))

        unlink(proxy_zip)  # 使用代理后,删除代理zip文件
    finally:
        if browser: browser.quit()
        if display: display.stop()
예제 #2
0
    def _clean(self):
        # Reset the directory data
        if (os.path.isdir(SLAPD_DATA)):
            shutil.rmtree(SLAPD_DATA)

        if (os.path.exists(SLAPD_CONFIG)):
            posix.unlink(SLAPD_CONFIG)

        if (os.path.exists(SLAPD_SOCKET)):
            posix.unlink(SLAPD_SOCKET)
예제 #3
0
    def _clean(self):
        # Reset the directory data
        if (os.path.isdir(SLAPD_DATA)):
            shutil.rmtree(SLAPD_DATA)

        if (os.path.exists(SLAPD_CONFIG)):
            posix.unlink(SLAPD_CONFIG)

        if (os.path.exists(SLAPD_SOCKET)):
            posix.unlink(SLAPD_SOCKET)
예제 #4
0
def mkrealdir(name):
    st = posix.stat(name)  # Get the mode
    mode = S_IMODE(st[ST_MODE])
    linkto = posix.readlink(name)
    files = posix.listdir(name)
    posix.unlink(name)
    posix.mkdir(name, mode)
    posix.chmod(name, mode)
    linkto = cat('..', linkto)
    #
    for file in files:
        if file not in ('.', '..'):
            posix.symlink(cat(linkto, file), cat(name, file))
예제 #5
0
def mkrealfile(name):
    st = posix.stat(name)  # Get the mode
    mode = S_IMODE(st[ST_MODE])
    linkto = posix.readlink(name)  # Make sure again it's a symlink
    f_in = open(name, 'r')  # This ensures it's a file
    posix.unlink(name)
    f_out = open(name, 'w')
    while 1:
        buf = f_in.read(BUFSIZE)
        if not buf: break
        f_out.write(buf)
    del f_out  # Flush data to disk before changing mode
    posix.chmod(name, mode)
예제 #6
0
def mkrealdir(name):
       st = posix.stat(name) # Get the mode
       mode = S_IMODE(st[ST_MODE])
       linkto = posix.readlink(name)
       files = posix.listdir(name)
       posix.unlink(name)
       posix.mkdir(name, mode)
       posix.chmod(name, mode)
       linkto = cat('..', linkto)
       #
       for file in files:
               if file not in ('.', '..'):
                       posix.symlink(cat(linkto, file), cat(name, file))
예제 #7
0
def mkrealfile(name):
       st = posix.stat(name) # Get the mode
       mode = S_IMODE(st[ST_MODE])
       linkto = posix.readlink(name) # Make sure again it's a symlink
       f_in = open(name, 'r') # This ensures it's a file
       posix.unlink(name)
       f_out = open(name, 'w')
       while 1:
               buf = f_in.read(BUFSIZE)
               if not buf: break
               f_out.write(buf)
       del f_out # Flush data to disk before changing mode
       posix.chmod(name, mode)
예제 #8
0
파일: crawl.py 프로젝트: zhguixin/python
 def filename(self,url,deffile='index.html'):
     re = urlparse(self.url,"http:",0)
     path = re[1]+re[2]
     ext = splitext(path)
     if ext[1]=='':
         if path[-1]=='/':
             path += deffile
         else:
             path += '/'+deffile
     ldir = dirname(path)
     
     if not isdir(ldir):
         if exists(ldir):
             unlink(ldir)
         makedirs(ldir)
     
     return path
            try:
                client = GraphAPI(token)
                client.request('me')
                fmutex('facebook').write(token)
                return client
            except GraphAPIError, e:
                print str(e)
                pass

        raise GraphAPIError('Unable to query GraphAPI')

    try:
        client = GraphAPI(file(cookie('facebook')).read())
        client.request('me')
    except GraphAPIError, e:
        unlink(cookie('facebook'))
        return login()
    return client


#access_token = None
#
#class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
#
#    def do_GET(self):
#        global access_token
#        self.send_response(200)
#        self.send_header("Content-type", "text/html")
#        self.end_headers()
#
#        if '/?code=' not in self.path:
예제 #10
0
        else:
            data = int(data[0]) + 1
    with open("status", "w") as fp:
        fp.write(str(data))
    return data
    

if __name__ == "__main__":
    SER.set_speed('115200', '8N1')
    SER.send('Welcome at the Watchdog Test.\r\n')

    try:
        count = get_status()
        if count == 3:
            SER.send("Maximum of reboots reached.\r\nIt all worked well... is not it marvelous\r\n")
            posix.unlink("status") 
            sys.exit(0)
    except Exception, value:
        SER.send("Exception error" + str(value) + "\r\n")

    #Init the HW WD
    time.sleep(1)        
    SER.send('Watchdog try : %d\r\n' % (count+1))
    SER.send('Waiting for module to be become fully operational (after boot)\r\n')
    time.sleep(20)          # wait for the module to be fully operational

    SER.send('Enable the Watch Dog\r\n')
    GPIO.setIOdir(8, 1, 1)  # GPIO8 in the HX910 unit is used for HW WD
    time.sleep(2)
    GPIO.setIOvalue(8, 0)
    # Hardware watch should be enabled now.
            try:
                client = GraphAPI(token)
                client.request('me')
                fmutex('facebook').write(token)
                return client
            except GraphAPIError, e:
                print str(e)
                pass

        raise GraphAPIError('Unable to query GraphAPI')

    try:
        client = GraphAPI(file(cookie('facebook')).read())
        client.request('me')
    except GraphAPIError, e:
        unlink(cookie('facebook'))
        return login()
    return client


#access_token = None
#
#class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
#
#    def do_GET(self):
#        global access_token
#        self.send_response(200)
#        self.send_header("Content-type", "text/html")
#        self.end_headers()
#
#        if '/?code=' not in self.path:
예제 #12
0
    with open("status", "w") as fp:
        fp.write(str(data))
    return data


if __name__ == "__main__":
    SER.set_speed('115200', '8N1')
    SER.send('Welcome at the Watchdog Test.\r\n')

    try:
        count = get_status()
        if count == 3:
            SER.send(
                "Maximum of reboots reached.\r\nIt all worked well... is not it marvelous\r\n"
            )
            posix.unlink("status")
            sys.exit(0)
    except Exception, value:
        SER.send("Exception error" + str(value) + "\r\n")

    #Init the HW WD
    time.sleep(1)
    SER.send('Watchdog try : %d\r\n' % (count + 1))
    SER.send(
        'Waiting for module to be become fully operational (after boot)\r\n')
    time.sleep(20)  # wait for the module to be fully operational

    SER.send('Enable the Watch Dog\r\n')
    GPIO.setIOdir(8, 1, 1)  # GPIO8 in the HX910 unit is used for HW WD
    time.sleep(2)
    GPIO.setIOvalue(8, 0)
예제 #13
0
            # Sets the gateway priority.
        try:
            conf = config.ConfFileParser(srv_conf_file, config.CONF_PRIORITY_SECTION)
            self.__gw_priority = conf.get_gw_priority()

        except Exception, e:
            self.__logger.error(e)
            sys.exit(1)

            # Creates and sets the socket.
        try:
            self.__sockd = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
            self.__sockd.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
            # bind() can fail if the pathname exists. So execute unlink() to delete.
            posix.unlink(sockPath)

        except OSError:
            # posix.unlink(): unix sock doesn't exist.
            pass

        except socket.error, e:
            self.__logger.error(str(e))
            sys.exit(1)

        self.__sockd.bind(str(sockPath))
        self.__sockd.listen(5)

    def __exec_client(self, id):
        factory = client_factory.ClientFactory()
        gw = factory.create(id, self.__config)