Esempio n. 1
1
def look_for_new_video():
    api_key = ''
    channel_id = 'UCV0qA-eDDICsRR9rPcnG7tw'

    base_video_url = 'https://www.youtube.com/watch?v='
    base_search_url = 'https://www.googleapis.com/youtube/v3/search?'

    url = base_search_url + f'key={api_key}&channelId={channel_id}&part=snippet,id&order=date&maxResults=1'
    inp = urllib.urloppen(url)
    resp = json.load(inp)

    vidID = resp['items'][0]['id']['videoId']

    video_exist = False
    with open('videoid.json', 'r') as json_file:
        data = json.load(json_file)
        if data['videoId'] != vidID:
            driver = webdriver.chrome()
            driver.get(base_video_url + vidID)
            video_exist = True

    if video_exist:
        with open('videoid.json', 'w') as json_file:
            data = {'videoId': vidID}
            json.dump(data, json_file)
Esempio n. 2
0
def look_for_new_video():
    api_key = "AIzaSyClhY61c_Be-M3baJMmOimHfDYlB_7mLN4"
    channel_id = "alectheblacksmith"

    base_video_url = 'https://www.youtube.com/watch?v='
    base_search_url = 'https://www.googleapis.com/youtuve/v3/search?'

    url = base_search_url + 'key={}&channelId={}&part=snippet,id&order=date&maxResults=1'.format(
        api_key, channel_id)
    inp = urllib.urloppen(url)
    resp = json.load(inp)

    vidID = resp['items'][0]['id']['videoId']

    video_exists = False
    with open('videoid.json', 'r') as json_file:
        data = json.load(json_file)
        if data['videoId'] != vidId:
            driver = webdriver.chrome()
            driver.get(base_video_url + vidID)
            video_exists = True

    if video_exists:
        with open('videoid.json', 'r') as json_file:
            data = {'videoId': vidID}
            json.dump(data, json_file)
    def signIn(self):
        if self.params['driver'] == 'chrome':
            self.driver = webdriver.chrome()
        elif self.params['driver'] == 'firefox':
            self.driver = webdriver.Firefox()
        elif self.params['driver'] == 'edge':
            self.driver = webdriver.edge()
        elif self.params['driver'] == 'ie':
            self.driver = webdriver.ie()
        elif self.params['driver'] == 'opera':
            self.driver = webdriver.opera()
        elif self.params['driver'] == 'safari':
            self.driver = webdriver.safari()
        else:
            return False  #driver undefined
        self.initDriver = True
        self.driver.get('https://www.linkedin.com/login')

        # signin
        user_field = self.driver.find_element_by_xpath(
            "//input[@id='username']")
        user_field.send_keys(self.params['email'])
        pass_field = self.driver.find_element_by_xpath(
            "//input[@id='password']")
        pass_field.send_keys(self.params['password'])
        self.driver.find_element_by_xpath(
            "//button[@data-litms-control-urn='login-submit']").click()
        return True
Esempio n. 4
0
def search_web(query):
    driver = webdriver.chrome(
        'E:\\FRIDAY\\chromedriver_win32\\chromedriver.exe')
    driver.implicitly_wait(1)
    driver.maximize_window()
    if 'youtube' in query.lower():
        speak("Opening in youtube")
        indx = query.lower().split().index('youtube')
        query = query.split()[indx + 1:]
        driver.get("http://www.youtube.com/results?search_query=" +
                   '+'.join(query))
        return
    else:
        if 'google' in query:
            indx = query.lower().split().index('google')
            query = query.split()[indx + 1:]
            driver.get("https://www.google.com/search?q=" + '+'.join(query))
        elif 'search' in query:
            indx = query.lower().split().index('google')
            query = query.split()[indx + 1:]
            driver.get("https://www.google.com/search?q=" + '+'.join(query))
        else:
            driver.get("https://www.google.com/search?q=" +
                       '+'.join(query.split()))
        return
Esempio n. 5
0
def look_for_new_videos():
    api_key = "AIzaSyBQaaj1wWtbNYfCaww2WjwF7pVlTKkMLZA"
    channel_id = "UCZfPrUL62TN74Mmrn-O_pZQ"

    base_video_url = 'https://www.youtube.com/watch?v='
    base_search_url = 'https://www.googleapis.com/youtube/v3/search?'

    url = base_search_url + 'key{}&channelId={}&part=snippet, id&order=date&maxResults=1'.format(
        api_key, channel_id)
    inp = urllib.request.urlopen(url)
    resp = json.load(inp)

    vidID = resp['items'][0]['id']['videoId']

    video_exists = False
    with open('videoid.json', 'r') as json_file:
        data = json.load(json_file)
        if data['videoId'] != vidID:
            driver = webdriver.chrome()
            driver.get(base_video_url + vidID)
            video_exists = True

    if video_exists:
        with open('videoid.json', 'w') as json_file:
            data = {'videoId': vidID}
            json.dump(data, json_file)
Esempio n. 6
0
 def test_Sample2(self):
     driver = webdriver.chrome("C:\\Users\\sony\\PycharmProjects\\SeleniumTest\\config\\chromedriver.exe")
     driver.get("https://www.bing.com/")
     input = driver.find_element_by_name("q")
     input.send_keys('chennai')
     input.send_keys(Keys.ENTER)
     input=driver.find_element_by_name("qqq")
Esempio n. 7
0
 def setUp(self):
     #self.driver = webdriver.Firefox()
     self.driver = webdriver.chrome()
     self.driver.implicitly_wait(30)
     self.base_url = "https://www.katalon.com/"
     self.verificationErrors = []
     self.accept_next_alert = True
Esempio n. 8
0
    def getWebDriverInstance(self):
        """
       Get WebDriver Instance based on the browser configuration

        Returns:
            'WebDriver Instance'
        """
        baseURL = "https://taskulu.com/account/login?go=login"

        if self.browser == "chrome":
            driver = webdriver.chrome()
        elif self.browser == "chrome":
            # Set chrome driver
            #driver = webdriver.Chrome()
            driverlocation = "/Users/romin/Desktop/selenium/chromedriver"
            os.environ["webdriver.chrome.driver"] = driverlocation
            driver = webdriver.Chrome(driverlocation)
        else:
            driverlocation = "/Users/romin/Desktop/selenium/chromedriver"
            driver = webdriver.Chrome(driverlocation)
        # Setting Driver Implicit Time out for An Element
        driver.implicitly_wait(3)
        # Maximize the window
        driver.maximize_window()
        # Loading browser with App URL
        driver.get(baseURL)
        return driver
Esempio n. 9
0
 def __init_(self, time, count, link):
     driver_Path = "C:\Users\betul\OneDrive\Belgeler\GitHub\amazon\chromedriver.exe"
     self.browser = webdriver.chrome(driver_Path)
     self.time = time
     self.count = count
     self.link = link
     Browser.goAmazon(self)
Esempio n. 10
0
    def __init__(self, username, password):
        self.username = username
        self.password = password

        if sys.platform == "linux" or sys.platform == "linux2":
            self.driver = webdriver.Firefox()
        else:
            self.driver = webdriver.chrome()
Esempio n. 11
0
    def __init__(sellf):
        self.navigateur_options = options()

        #pour que le navigateur fonctionnne en arrière plan
        self.navigateur_options.add_argument('--headless')

        #le chemin vers notre chromedriver.exe, vérifier bien que ce driver support la version de votre google chrome
        self.browser = webdriver.chrome(
            "C:/Users/USER/Downloads/chromedriver_win32/chromedriver.exe",
            options=self.navigateur_options)
Esempio n. 12
0
def main():
    content = sys.argv[1]
    content.replace('', '+')
    no_images = int(sys.argv[2])
    number_scrolls = no_images / 100 + 1
    path = 'C:\Python27/abcdownload'

    if not os.path.exists(path):
        os.mkdir(path)

    url = "https://www.google.co.in/search?q=" + content + "&rlz=1C1ASRW_enIN750IN750&source=lnms&tbm=isch&sa=X&ved=0ahUKEwj9y8-RtsjYAhWLYo8KHTP9BZYQ_AUICygC&biw=1745&bih=841"
    headers = {}
    headers[
        'User-Agent'] = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"
    driver = webdriver.chrome(
        'C:\Program Files (x86)\Google\Chrome\Application\chrome')
    # driver.open(driver+url)
    #while(no_images>0):
    #   driver.find_element_by_xpath('// * [ @ id = "rg_s"] / div[i] / a / img').click()
    #    no_images+=1
    extensons = ['jpg', 'jpeg', 'png']
    img_count = 0
    downloaded_images = 0

    for _ in xrange(number_scrolls):
        for _ in xrange(10):
            driver.execute_script("window.scrollBy(0,1000)")
            time.sleep(1)
        try:
            driver.find_element_by_xpath(
                "//input[@value='Show more results']").click()
        except Exception as e:
            print(str(e))

    images = driver.find_element_by_xpath('//div[contains(@class,"rg_meta")]')
    for img in images:
        no_images += 1
        img_url = json.loads(img.get_attribute('innerHTML'))['ou']
        img_type = json.loads(img.get_attribute('innerHTML'))['ity']
        print "Image ", img_count, " is being downloaded from ", img_url
        try:
            if img_type not in extensons:
                continue
            else:
                req = requests.get(img_url, headers=headers)
                raw_image = urllib.urlopen(req).read()
                f = open(path + img_type, 'w')
                f.write(raw_image)
                downloaded_images += 1
        except Exception as e:
            print(str(e) + ' is why you cannot download image')

        if downloaded_images > no_images:
            break
        driver.quit()
Esempio n. 13
0
 def process_request(self,request, spider):
     if request.meta.get('selenium'):
         chrome_options = Options()
         chrome_options.add_argument('--headless')
         driver = webdriver.chrome(chrome_options=chrome_options)
         driver.get(request.url)
         time.sleep(1)
         html = driver.page_source
         driver.quit()
         return HtmlResponse(url=request.url,body=html,encoding='utf-8',request=request)
     return None
Esempio n. 14
0
def get_driver_instance():
    browser = pytest.config.option.browser.lower()
    url = pytest.config.option.server.lower()

    if browser == 'firefox':
        driver = firefox("./browser-servers/geckodriver.exe")
    elif browser == 'chrome':
        driver = chrome("./browser-servers/chromedriver.exe")
    elif browser == 'ie':
        driver = chrome("./browser-servers/internetexplorer.exe")
    else:
        print('invalid browser option')
        return None
    driver.maximize_window()
    driver.implicitly_wait(30)
    if url == 'prod':
        driver.get('https://demo.actitime.com')
    else:
        driver.get("https:localhost")
    return driver
Esempio n. 15
0
def scrape(symbol):
    driver = webdriver.chrome('/Users/jorgecorradi/devenv/chromedriver')
    driver.get('http://www.google.com/')
    time.sleep(5)  # Let the user actually see something!
    search_box = driver.find_element_by_name('q')
    search_box.send_keys('ChromeDriver')
    search_box.submit()
    time.sleep(5)  # Let the user actually see something!
    driver.quit()

    quote = {'symbol': symbol, 'last_price': 0.12}
    return jsonify(quote), 200
Esempio n. 16
0
 def test1(self):
     #self.driver=webdriver.Ie()
     self.driver = webdriver.chrome()
     self.driver.get("http://10.5.86.208/TBM3")
     self.driver.implicitly_wait(3)
     self.driver.maximize_window()
     self.driver.find_element(By.ID, "txtUserName").send_keys("sysadmin")
     self.driver.find_element(By.ID, "txtPassword").send_keys("sinopec")
     #self.driver.find_element_by_id("btnLogin").send_keys(Keys.ENTER)
     #self.driver.find_element(By.ID, "btnLogin").click()
     pub=PublicUse
     pub.ele_click(self,"id","btnLogin")
     pub.ele_click(self,"xpath","//*[@id=‘menu’]/div[5]/div[1]/div[1]")
Esempio n. 17
0
def get_driver_instance():
    browser = pytest.config.option.type.lower()
    if browser == 'chrome':
        driver = chrome("./browser-server/chromedriver.exe")
    elif browser == 'firefox':
        driver = firefox("./browser-server/geckodriver.exe")
    else:
        print('Invalid Browser Option')
        return None
    driver.maximize_window()
    driver.implicitly_wait(30)
    driver.get("http://localhost")
    return driver
Esempio n. 18
0
def crolling(baseUrl,keyword):
    # baseUrl = 'https://www.instagram.com/explore/tags/'   # find by tags
    # baseUrl = 'https://www.instagram.com/'                # find by account
    plusUrl = keyword

    url = baseUrl + quote_plus(plusUrl)
    try :
        driver = webdriver.Chrome()
    except :
        driver = webdriver.chrome(driver_path)

    driver.get(url)

    # infinite page down
    thread1 = threading.Thread(target=execute,args=(driver,))
    thread1.start()
    thread2 = threading.Thread(target=download)
    thread2.start()
    i = 1

    global links
    global already_downloaded

    while True:

        if i >= len(htmls):
            tmp = len(htmls)
            time.sleep(2)
            if loading_end:
                links = list(set(links))
                return links
                break
            continue
        else :
            soup = BeautifulSoup(htmls[i], 'html.parser')
        try:
            imgs = soup.select('.v1Nh3.kIKUG._bz0w a img')
            for src in imgs:
                links.append(src['src'])
            print(str(i)+"번째 로딩 기록...")
            i += 1
        except Exception as e:
            print(e)
            print(Exception)
            time.sleep(1)



        time.sleep(0.3)
    return links
Esempio n. 19
0
    def __init__(self,driver: WebDriver = None,reuse=False):
        if driver is None:
            if reuse:
                options = webdriver.ChromeOptions()
                options.debugger_address = "127.0.0.1:9222"
                self._driver = webdriver.chrome(options=options)
            else:
                self._driver = webdriver.Chrome()
            self._driver.implicitly_wait(3)
        else:
            self._driver = driver
        self._driver.maximize_window()

        if self._base_url !="":
            self._driver.get(self._base_url)
Esempio n. 20
0
def get_chrome_driver(silent):
    options = ChromeOptions()
    if silent:
        options.add_argument("--mute-audio")
        options.add_argument("--headless")
        options.add_argument("--window-size=1366x768")
    options.add_argument("--lang=en-us")
    executable_path = determine_exec("chrome")
    if executable_path == None:
        print("Cannot determine operating system")
        try:
            return webdriver.chrome(chrome_options=options)
        except Exception:
            print("Cannot find chromedriver executable")
    else:
        return webdriver.Chrome(executable_path=executable_path,
                                chrome_options=options)
Esempio n. 21
0
    def __init__(self):
        #self.channels = ["tv","movie","child","variety","cartoon","doco"]
        self.channels = [
            "index.html", "index_2.html", "index_4.html", "index_3.html",
            "index_guoxue.html", "index_english.html", "index_ps.html",
            "index_yuer.html"
        ]
        #self.channels = ["child"]
        self.baseUrl = 'http://www.baobao88.com/lianbo/'
        self.file_path = f'.//baobao88//'
        self.file_json = f'.//json//'
        self.headers = {
            'user-agent':
            'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0',
            'Accept': '*/*'
        }
        self.data_float_url = 'https://node.video.qq.com/x/api/float_vinfo2?cid='

        self.brower = webdriver.chrome()
Esempio n. 22
0
def main(question):
    #import libraries
    from selenium import webdriver
    from selenium.webdriver.common.keys import keys
    from selenium.webdriver.chrome.options import Options

    #configure some options
    options = Options(
    )  #get the selenium.webdriver.chrome.options Options() function.
    options.add_experimental_option("excludeSwitches", ['enable-automation'])

    #get the browser
    browser = webdriver.chrome(options=options)
    browser.get("https://www.google.com/")

    #find the search bar and send over the search query
    elem = browser.find_element_by_name("q")
    elem.clear()
    elem.send_keys(question)
    elem.send_keys(keys.RETURN)
Esempio n. 23
0
def main():
    driver = webdriver.chrome(executable_path=browserPath, chrome_options=chrome_options)
    driver.get(homePage)  # 访问目标网页
    bsObj = BeautifulSoup(driver.page_source, parser)  # 解析html代码
    print("[*]OK GET Page")
    # 获得主页上所有MM的姓名、所在城市、身高、体重等信息
    girlsList = driver.find_element_by_id('J_GirlsList').text.split('\n')
    # print(girlsList)
    # 获取所有MM封面图片
    imagesUrl = re.findall('\/\/gtd\.alicdn\.com\/sns_logo.*\.jpg', driver.page_source)
    # 获取个人主页地址等信息
    girlsUrl = bsObj.find_all(
        "a",
        {"href": re.compile("\/\/.*\.htm\?(userId=)\d*")})
    # 获取名字地点
    girlsNL = girlsList[::3]
    # 身高体重
    girlsHW = girlsList[1::3]
    # 个人主页地址
    girlsHURL = [('http:' + i['href']) for i in girlsUrl]
    # 封面照地址
    girlsPhotoURL = [('https:' + i) for i in imagesUrl]

    girlsInfo = zip(girlsNL, girlsHW, girlsHURL, girlsPhotoURL)

    # 姓名地址girlNL,身高体重girlHW,个人主页地址girlHRUL,封面图片URL
    for girlNL, girlHW, girlHURL, girlCover in girlsInfo:
        print("[*]Girl :", girlNL, girlHW)
        # 为妹子建立文件夹
        mkdir(outputDir + girlNL)
        print("    [*]saving...")
        # 获取妹子封面图片
        data = urlopen(girlCover).read()
        with open(outputDir + girlNL + '/cover.jpg', 'wb') as f:
            f.write(data)
        print("    [+]Loading Cover...")
        # 获取妹子个人主页中的图片
        getImgs(girlsHURL, outputDir + girlsNL)
    driver.close()
Esempio n. 24
0
    def get_web_driver_instance(self):
        """
       Get WebDriver Instance based on the browser configuration

        Returns:
            'WebDriver Instance'
        """
        if self.browser == "iexplorer":
            # Set ie driver
            driver = webdriver.Ie()
        elif self.browser == "firefox":
            driver = webdriver.Firefox()
        elif self.browser == "chrome":
            driver = webdriver.chrome()
        else:
            driver = webdriver.Firefox()
        # Setting Driver Implicit Time out for An Element
        driver.implicitly_wait(3)
        # Maximize the window
        driver.maximize_window()
        # Loading browser with App URL
        driver.get(BASE_URL)
        return driver
Esempio n. 25
0
 def setUp(self):
     self.mylog = log()
     self.driver = webdriver.chrome()
     self.url = 'https://www.sogou.com/'
     self.sogou_page = sogou_page(self.driver, self.url, u'搜狗')
     self.excel = excel_data.excel()
Esempio n. 26
0
from selenium import webdriver

from selenium.webdriver.common.keys import Keys

driver = webdriver.chrome(r'D:/cromedriver/chromedriver.exe')

driver.get(
    "https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Generic_views"
)

print(driver.title)  # title of the page

driver.close()
Esempio n. 27
0
import selenium
from selenium import webdriver
browser = webdriver.chrome()
Esempio n. 28
0
from selenium import webdriver as wd
driver = wd.chrome(executable_path='C:\Program Files\chromedriver.exe')
driver.get('https://youtube.com')
Esempio n. 29
0
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep

driver = webdriver.chrome(
    executable_path="/Users/talhaDocs/Downloads/chromedriver")

driver.get(
    "https://stackoverflow.com/users/signup?ssrc=head&returnurl=%2Fusers%2Fstory%2Fcurrent%27"
)
sleep(3)
driver.find_element_by_xpath('//*[@id="openid-buttons"]/button[1]').click()
driver.find_element_by_xpath('//input[@type="email"]').send_keys("email here")
driver.find_element_by_xpath('//*[@id="identifierNext]').click()
sleep(3)
driver.find_element_by_xpath('//input[@type="password"]').send_keys(
    "password here")
driver.find_element_by_xpath('//*[@id="passwordNext"]').click()
sleep(3)
for i in range(20):
    driver.get("https://mail.google.com/mail/u/0/#inbox?compose=new")
    sleep(3)
    driver.find_element_by_class_name("vO").send_keys("recipient here")
    driver.find_element_by_class_name("aoT").send_keys("subject here")
    driver.find_element_by_css_selector(
        "div[aroa-label='Message body']").send_keys("la la land")
    driver.find_element_by_xpath("//div[text()='Send']").click()
    sleep(3)
Esempio n. 30
0
 def login(self):
     d = webdriver.chrome()
     d.get(url)
     d.maximize_window()
Esempio n. 31
0
 def setUp(self):
     self.dr = webdriver.chrome()
Esempio n. 32
0
#!/usr/bin/python3

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException

def handle_alert():
    WebDriverWait(browser, 3).until(EC.alert_is_present(),
                                   'Timed out waiting for PA creation ' +
                                   'confirmation popup to appear.')

    alert = browser.switch_to.alert
    alert.accept()
    print("alert accepted")


if __name__ == '__main__':
	driver = webdriver.chrome('/Users/deepak/Documents/chromedriver')
	driver.get('https://mynasadata.larc.nasa.gov/latitudelongitude-finder/?lat=&lng=')
	driver.find_element_by_id('gadres').send_keys('python')
	driver.find_element_by_id('lat').send_keys('12')
	driver.find_element_by_id('lng').send_keys('13')
	driver.find_element_by_type('button').click()
	try:
		handle_alert()
	except TimeoutException:
		print('No Alert')


Esempio n. 33
0
#coding=utf-8
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.action_chains import ActionChains
import unittest, time, re
import login

login_url = 'http://localhost/wordpress/wp.login.php'
post_list_url = 'http://localhost/wordpress/wp-admin/edit.php'

def setup(self)
  self.dr = webdriver.chrome()

def test_login(self):
    self.login()
    print self.dr.current_url
    self.assertTrue('wp-admin'in self.dr.current_url)





class Rename(unittest.TestCase):
    
    def setUp(self):
        self.driver = webdriver.Firefox()
        self.driver.implicitly_wait(30)