Use xvfbwrapper for Firefox
This commit is contained in:
parent
5a6a05cab9
commit
90e997a500
1 changed files with 6 additions and 12 deletions
18
handler.py
18
handler.py
|
@ -4,6 +4,7 @@ from bs4 import BeautifulSoup
|
|||
from selenium import webdriver
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
from selenium.common.exceptions import NoSuchElementException
|
||||
from xvfbwrapper import Xvfb
|
||||
import multiprocessing, urllib.request, urllib.error, urllib.parse, time, os
|
||||
import dbtools, phototools, setuptools
|
||||
|
||||
|
@ -126,20 +127,13 @@ def siteHandler(driver, mode = 0, p = 0, db = dbtools.dbHelper()):
|
|||
if pageHandler(driver, db):
|
||||
siteHandler(driver, mode, p+1, db)
|
||||
|
||||
def mainHandler():
|
||||
def mainHandler(driver, db):
|
||||
siteHandler(driver, 0, db=db)
|
||||
siteHandler(driver, 1, db=db)
|
||||
|
||||
if __name__ == "__main__":
|
||||
db = dbtools.dbHelper()
|
||||
driver = webdriver.Firefox()
|
||||
try:
|
||||
if loginHandler(driver):
|
||||
p = multiprocessing.Process(target=mainHandler)
|
||||
p.start()
|
||||
p.join(1500)
|
||||
if p.is_alive():
|
||||
p.terminate()
|
||||
p.join()
|
||||
finally:
|
||||
with Xvfb() as xvfb:
|
||||
db = dbtools.dbHelper()
|
||||
driver = webdriver.Firefox()
|
||||
mainHandler(driver, db)
|
||||
driver.close()
|
||||
|
|
Loading…
Reference in a new issue