123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- from selenium import webdriver
- from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
- import time
- import os
- import datetime
- import urllib.parse
- from selenium.webdriver.support.ui import WebDriverWait
- from selenium.webdriver.common.by import By
- from selenium.webdriver.support import expected_conditions as EC
- import codecs
- from selenium.webdriver.common.by import By
- import random
- from bs4 import BeautifulSoup
- import requests
- import time
- import rpyc
- import sys
- import docker
- import googlesearch
- import codecs
- import sys
- import time
- import dataset
- import os
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/hhh?charset=utf8mb4')
- #cursor=db.query('SELECT kw FROM hhh.hhh_contentgap_serp where ranking is not null;')
- #cursor=db.query('SELECT kw FROM hhh.hhh_contentgap_serp where kw not in (select distinct kw from hhh_contentgap_serp where id >= 155)')
- kwlst={}
- #for c in cursor:
- # kwlst[c['kw']]=1
- table=db['hhh_contentgap_serp']
- curdir=os.path.realpath('.')
- #fr=codecs.open(curdir+os.sep+'contentgap.txt','r','utf-8')
- #fr=codecs.open(curdir+os.sep+'hhh\\seo\\contentgap.txt','r','utf-8')
- fr=codecs.open('C:\\gitlab\\kw_tools\\kw_tools\\hhh\\SEO\\contentgap.txt','r','utf-8')
- lines=fr.readlines()
- lst=[]
- for l in lines:
- lst.append(l.replace('\n',''))
- headers = {
- "Authorization": "Bearer " + "t35vhZtWNgvDNWHc3DJh0OKll3mcB9GvC8K2EAkBug2",
- "Content-Type": "application/x-www-form-urlencoded"
- }
- def restart_browser():
- options = webdriver.ChromeOptions()
- options.add_argument('user-data-dir=c:/tmp/profile')
- options.add_argument('--profile-directory=Default')
- driver=webdriver.Chrome(options=options)
- driver.set_window_size(1400,1000)
- return driver
- driver=restart_browser()
- driver.get('https://liff.googo.org/liff2/')
- time.sleep(10)
- elmt=driver.find_element(By.XPATH,"//button[@id='senddm']")
- webdriver.ActionChains(driver).move_to_element(elmt).perform()
- webdriver.ActionChains(driver).move_to_element(elmt).click().perform()
- time.sleep(12)
- #time.sleep(99999)
- for window_handle in driver.window_handles:
- # driver.switch_to(window_handle)
- driver.switch_to.window(window_handle)
- print(driver.title)
- if ('選擇傳送對象' in driver.title ) or ('Share with' in driver.title):
- driver.maximize_window()
- print('ok')
- # class="c-checkbox"
- # elmts=driver.find_elements(By.XPATH,"//input[@type='checkbox']")
- elmts=driver.find_elements(By.XPATH,"//div[@class='c-checkbox']")
- for elmt in elmts:
- print(elmt.text)
- # if elmt.text != 'LINE':
- # if 'ChoozMo' in elmt.text :
- if 'Jared' in elmt.text :
- if len(elmt.text)>2:
- # inp=elmt.find_element(By.TAG_NAME,"input")
- inp=elmt.find_element(By.XPATH,".//input")
- # elem = driver.switch_to.active_element
- print(inp)
- # inp.click()
- webdriver.ActionChains(driver).move_to_element(inp).perform()
- # d3 = driver.switch_to.active_element
- webdriver.ActionChains(driver).move_to_element(inp).click().perform()
- elmt2=driver.find_element(By.XPATH,"//button[@name='allow']")
- webdriver.ActionChains(driver).move_to_element(elmt2).perform()
- webdriver.ActionChains(driver).move_to_element(elmt2).click().perform()
- #elmt.input.click()
-
-
- # if window_handle != original_window:
- # driver.switch_to.window(window_handle)
- # break
- time.sleep(9999)
|