12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- import time
- import json
- from selenium import webdriver
- from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
- import time
- import os
- 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
- from selenium.webdriver.common.keys import Keys
- import codecs
- import random
- import requests
- import datetime
- import dataset
- import time
- import traceback
- import sys
- import fire
- def init_browser():
- os.system('docker container restart proxy1')
- os.system('docker container restart tiny1')
- time.sleep(10)
- options = webdriver.ChromeOptions()
- options.add_argument('--headless')
- options.add_argument('--proxy-server=socks5://127.0.0.1:9050')
- options.add_argument('--disable-dev-shm-usage')
- options.add_argument('--no-sandbox')
- # options.add_argument('--remote-debugging-port=9222')
- # epath=os.environ['WEBDRIVER']
- options.add_experimental_option("debuggerAddress", "127.0.0.1:9922")
- # options.add_experimental_option("debuggerAddress", "192.168.192.45:9922")
- # options.add_experimental_option("debuggerAddress", q[2])
- # options.add_argument("--user-agent=" +user_agent)
- options.add_argument("--incognito")
- driver = webdriver.Chrome(executable_path=r'C:\portable\webdriver\chrome98\chromedriver.exe',options=options)
- # driver = webdriver.Chrome(executable_path=epath,options=options)
- driver.delete_all_cookies()
- driver.set_window_size(1400,1000)
- return driver
- print(q)
- process_query(q)
- driver=init_browser()
- #driver.get('https://www.youtube.com/watch?v=K5DEJXajtqA')
- driver.get('https://www.youtube.com/watch?v=_N0VneVhkoQ')
- video = driver.find_element_by_id('movie_player')
- video.send_keys(Keys.SPACE) #hits space
- time.sleep(1)
- video.click() #mouse click
- time.sleep(31)
|