|
@@ -0,0 +1,62 @@
|
|
|
+from selenium import webdriver
|
|
|
+from selenium.webdriver.chrome.service import Service
|
|
|
+from selenium.webdriver.common.by import By
|
|
|
+from selenium.webdriver.common.keys import Keys
|
|
|
+import time
|
|
|
+
|
|
|
+
|
|
|
+def scrolling(driver, pgnum):
|
|
|
+ ub = driver.find_element("css selector",'body')
|
|
|
+ for i in range(pgnum):
|
|
|
+ ub.send_keys(Keys.PAGE_DOWN)
|
|
|
+ if pgnum > 1:
|
|
|
+ time.sleep(0.3)
|
|
|
+
|
|
|
+def process_query():
|
|
|
+ global driver
|
|
|
+ url = 'https://hhh.com.tw/HHH_NEW/designers/index_designerList.php?cid=807'
|
|
|
+ driver.get(url)
|
|
|
+
|
|
|
+ print('這裡')
|
|
|
+ time.sleep(3)
|
|
|
+ print(driver.current_url)
|
|
|
+ scrolling(driver, 1)
|
|
|
+ time.sleep(3)
|
|
|
+ elmt = driver.find_element(By.XPATH,'/html/body/div[2]/section[3]/div/div[1]/div/div[3]/div[1]/aside[6]/div[2]')
|
|
|
+ driver.maximize_window()
|
|
|
+
|
|
|
+ webdriver.ActionChains(driver).move_to_element(elmt).perform()
|
|
|
+ webdriver.ActionChains(driver).move_to_element(elmt).click().perform()
|
|
|
+
|
|
|
+ time.sleep(6)
|
|
|
+ driver.quit()
|
|
|
+
|
|
|
+
|
|
|
+def run_once():
|
|
|
+ global driver
|
|
|
+ result = []
|
|
|
+ user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36'
|
|
|
+ s = Service('C:\/Users\/s1301\/Downloads\/chromedriver_110\/chromedriver')
|
|
|
+ options = webdriver.ChromeOptions()
|
|
|
+ # options.add_argument('--headless')
|
|
|
+ # options.add_argument('--remote-debugging-port=9222')
|
|
|
+ # options.add_experimental_option("debuggerAddress", "192.168.192.45:9922")
|
|
|
+ options.add_argument("--user-agent=" + user_agent)
|
|
|
+ options.add_argument("--incognito")
|
|
|
+ # options.add_argument('--proxy-server=socks5://172.104.93.163:41800')
|
|
|
+ driver = webdriver.Chrome(
|
|
|
+ options=options, service=s)
|
|
|
+
|
|
|
+
|
|
|
+ process_query()
|
|
|
+ time.sleep(3)
|
|
|
+ driver.quit()
|
|
|
+
|
|
|
+count = 0
|
|
|
+while count<6:
|
|
|
+ try:
|
|
|
+ run_once()
|
|
|
+ count+=1
|
|
|
+ except:
|
|
|
+ pass
|
|
|
+
|