Jared 2 år sedan
förälder
incheckning
c578262810
4 ändrade filer med 148 tillägg och 4 borttagningar
  1. 14 0
      choozmo/fetch_content.py
  2. 109 0
      choozmo/meta_1777.py
  3. 19 4
      choozmo/priv_seo.py
  4. 6 0
      choozmo/privseo.bat

+ 14 - 0
choozmo/fetch_content.py

@@ -0,0 +1,14 @@
+
+from bs4 import BeautifulSoup
+import requests
+import html2text
+
+# request web page
+resp = requests.get("https://casino543.com/2021%E5%B9%B4%E5%8D%81%E5%A4%A7%E7%B7%9A%E4%B8%8A%E5%A8%9B%E6%A8%82%E5%9F%8E%E6%8E%92%E5%90%8D%E6%8E%A8%E8%96%A6-%E5%A8%9B%E6%A8%82%E5%9F%8E%E5%89%8D100%E5%90%8D%E5%A8%9B%E6%A8%82%E5%9F%8E%E9%82%84/")
+html = resp.content
+html=html.decode('utf-8')
+h = html2text.HTML2Text()
+
+h.ignore_links = True
+print (h.handle(html ))
+

+ 109 - 0
choozmo/meta_1777.py

@@ -0,0 +1,109 @@
+#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
+
+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:
+        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:
+#            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 run_once(url):
+    global driver
+    i=random.randint(0,7)
+    if i==0 or driver is None:
+        time.sleep(8)
+        re_get_webdriver()
+    if driver is None:
+        return
+    try:
+        driver.get(url)
+        time.sleep(8)
+        
+        elmt = driver.find_element(By.XPATH, "//a[contains(@href,'HxXfN9r')]")
+        webdriver.ActionChains(driver).move_to_element(elmt).perform()
+        webdriver.ActionChains(driver).move_to_element(elmt).click().perform()
+        time.sleep(10)
+        driver.quit()
+        print("DONE!!!!")
+#        driver.execute_script('window.open("'+url+'","_blank");')
+#        driver.execute_script("window.scrollTo(0, window.scrollY + 400)")
+#        time.sleep(0.5)
+    except:
+        print('exception')
+        time.sleep(9999)
+
+
+lst=[]
+
+
+
+#lst=['https://www.hhh.com.tw/columns/detail/3427/index.php']
+    #for i in range(20):
+while True:
+    l='https://cmm.ai/meta'
+    print(l)
+    run_once(l)
+    time.sleep(2)
+

+ 19 - 4
choozmo/priv_seo.py

@@ -41,7 +41,7 @@ def re_get_webdriver():
         options = webdriver.ChromeOptions()
         options.add_argument("--no-sandbox")
         options.add_argument("--disable-dev-shm-usage")
-        options.add_argument("--headless")
+#        options.add_argument("--headless")
 
         print(user_agent)
 #        options.add_argument("--user-agent=" +user_agent)
@@ -55,7 +55,8 @@ def re_get_webdriver():
             os.system('kill %d' % os.getpid())
             sys.exit()
             return
-        driver.set_window_size(1400,1000)
+#        driver.set_window_size(1400,1000)
+        driver.minimize_window()
         return
     except:
         import traceback
@@ -70,7 +71,7 @@ def from_shopping(kw):
     driver.get('https://shopping.google.com')
     time.sleep(5)
     elmt = driver.find_element(By.XPATH, "//input[@id='REsRA']")
-    elmt.send_keys('幸福空間') 
+    elmt.send_keys(kw) 
     elmt.send_keys(Keys.ENTER) #hits space
     time.sleep(7)
     elmt = driver.find_element(By.XPATH, "//div[@class='hdtb-mitem']/a[contains(text(),'全部') or contains(text(),'All')]")
@@ -83,7 +84,7 @@ def from_book(kw):
     driver.get('https://books.google.com/')
     time.sleep(5)
     elmt = driver.find_element(By.XPATH, "//input[@id='oc-search-input']")
-    elmt.send_keys('幸福空間') 
+    elmt.send_keys(kw) 
     elmt.send_keys(Keys.ENTER) #hits space
     time.sleep(7)
     elmt = driver.find_element(By.XPATH, "//div[@class='hdtb-mitem']/a[contains(text(),'全部') or contains(text(),'All')]")
@@ -187,6 +188,7 @@ def from_ekoru(kw):
 
 
 
+
 def from_yahoo(kw):
     global driver
     driver.get('https://search.yahoo.com/search?p=google')
@@ -222,12 +224,23 @@ def from_gibiru(kw):
     time.sleep(6)
 
 
+def from_google(kw):
+    global driver
+    driver.get('https://www.google.com?num=30')
+    print(kw)
+    time.sleep(4)
+    elmt = driver.find_element(By.XPATH, "//input[@name='q']")
+    time.sleep(1)
+    elmt.send_keys(kw)
+    elmt.send_keys(Keys.ENTER)
+    time.sleep(6)
 
 def run_once(jsobj):
     global driver
 
 
     i=random.randint(0,9)
+    i=10
     if driver is None:
         time.sleep(8)
         re_get_webdriver()
@@ -263,6 +276,8 @@ def run_once(jsobj):
             from_ecosia(kw)
         elif i==9:
             from_brave(kw)
+        else:
+            from_google(kw)
 #        time.sleep(9999)
         elmts = driver.find_elements(By.XPATH, "//div[@class='yuRUbf']/a")
 

+ 6 - 0
choozmo/privseo.bat

@@ -0,0 +1,6 @@
+@echo off
+:while
+(
+   python priv_seo.py
+   goto :while
+)