from selenium import webdriver
import threading
from multiprocessing import Queue
from selenium.webdriver.common.by import By
q = Queue()
queue_chrome=Queue()
def selenium_hw():
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--disable-gpu') # 谷歌文档提到需要加上这个属性来规避bug
#chrome_options.add_argument('--hide-scrollbars') # 隐藏滚动条, 应对一些特殊页面
chrome_options.add_argument('blink-settings=imagesEnabled=false') # 不加载图片, 提升速度
id="随便写个用户名吧"
pwd="随便写个密码吧"
browser= webdriver.Chrome(chrome_options=chrome_options)
chrome_para=queue_chrome.get()
print(chrome_para)
browser.set_window_size(chrome_para[2], chrome_para[3])
browser.set_window_position(chrome_para[0], chrome_para[1])
browser.get("https://hwid1.vmall.com/CAS/portal/login.html?loginChannel=26000000&reqClientType=26&lang=zh-CN&countryCode=cn&validated=true&themeName=red&service=https%3A%2F%2Fwww.vmall.com%2Faccount%2Fcaslogin%3Furl%3Dhttps%253A%252F%252Fsale.vmall.com%252Fhwmate.html%253Fcid%253D10600")
xpath_id="//*[@id=\"loginform\"]/div/div/div[1]/div[2]/div[1]/div/table/tbody/tr[1]/td/label/div"
xpath_pwd="//*[@id=\"login_password\"]"
xpath_btn_login="//*[@id=\"btnLogin\"]"
element_id=browser.find_element(By.XPATH,xpath_id)
element_id.send_keys(id)
element_id=browser.find_element(By.XPATH,xpath_pwd)
element_id.send_keys(pwd)
#element_id=browser.find_element(By.XPATH,xpath_btn_login)
#element_id.click()
#browser.execute_script('window.scrollTo(0, document.body.scrollHeight)')
#browser.execute_script('alert("To Bottom")')
def gen_para():
x=-1920
y=1
long=475
high=300
reslution_x=1920
queue_chrome.put([x, y, long, high])
for i in range(39):
if(x+long>=reslution_x):
y=y+high
x=-1920
else:
x = x + long
queue_chrome.put([x,y,long,high])
if __name__ == '__main__':
gen_para()
for i in range(40):
t = threading.Thread(target=selenium_hw)
t.start()
while True:
print(q.get())
print(threading.currentThread())
print(threading.enumerate())
print(threading.activeCount())