Explorar el Código

Merge remote-tracking branch 'origin/master'

zooey hace 2 años
padre
commit
5ee113e339
Se han modificado 1 ficheros con 97 adiciones y 0 borrados
  1. 97 0
      website_clickjobs/type-3/icons.py

+ 97 - 0
website_clickjobs/type-3/icons.py

@@ -0,0 +1,97 @@
+#import redis
+import time
+import traceback
+#import json
+from selenium import webdriver
+from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
+import time
+import os
+from selenium.webdriver.support.ui import WebDriverWait
+from selenium.webdriver.common.by import By
+from selenium.webdriver.support import expected_conditions as EC
+import dataset
+from selenium.webdriver.common.keys import Keys
+
+import json
+import random
+import time
+import sys
+import codecs
+import random
+import os
+import time
+from userAgentRandomizer import userAgents
+
+driver=None
+def re_get_webdriver():
+    global driver
+    result=[]
+    if driver is not None:
+        print('closing....')
+        driver.quit()
+        os.system('killall chrome')
+        print('quit....')
+        driver=None
+    try:
+        print('begin..')
+        ua = userAgents()
+
+        user_agent = ua.random()        
+
+        options = webdriver.ChromeOptions()
+
+
+        mobile_emulation = {
+            "deviceMetrics": { "width": 360, "height": 640, "pixelRatio": 3.0 },
+            "userAgent": "Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19" }
+#        options.add_experimental_option("mobileEmulation", mobile_emulation)
+
+        options.add_argument("--no-sandbox")
+        options.add_argument("--disable-dev-shm-usage")
+        options.add_argument("--headless")
+
+#        print(user_agent)
+#        options.add_argument("--user-agent=" +user_agent)
+        options.add_argument("--incognito")
+        driver=None
+        try:
+            driver = webdriver.Chrome(options=options)
+        except:
+            traceback.print_exc()
+#            driver.quit()
+#            os.system('pkill -f ')
+            os.system('kill %d' % os.getpid())
+            sys.exit()
+            return
+#        driver.set_window_size(1400,1000)
+        return
+    except:
+        import traceback
+        traceback.print_exc()
+        driver=None
+        return None
+
+
+def scrolling(driver,pgnum):
+    ub = driver.find_element_by_css_selector('body')
+    for i in range(pgnum):
+        ub.send_keys(Keys.PAGE_DOWN)
+        if pgnum>1:
+            time.sleep(0.3)
+
+
+re_get_webdriver()
+
+lst=[]
+
+url='https://theicons.net/'
+driver.get(url)
+time.sleep(3)
+for i in range(7):
+    driver.execute_script('window.open("'+url+'","_blank");')
+    driver.execute_script("window.scrollTo(0, window.scrollY + 400)")
+    time.sleep(0.5)
+
+time.sleep(15)
+driver.quit()
+sys.exit()