Exemplo n.º 1
0
def add_to_friends(link):
    driver.get(link)
    try:
        add = driver.find_element_by_xpath("//a[@class='button wide_button acceptFriendBtn']")
        add.click()
    except:
        debug_screenshot("VK_add_to_friends_")
Exemplo n.º 2
0
def checker_1_4(url):
    driver.get(url)

    audios = driver.find_elements_by_css_selector("audio")
    audio_score = None
    if audios:
        audio_total = len(audios)
        audio_good_total = sum(
            [1 for audio in audios if audio.get_attribute("controls")])
        audio_score = audio_good_total / len(audios)
    zoom_score = 1
    return {
        "total_score": ((audio_score or 1) + zoom_score) / 2,
        "subs": [{
            "name":
            "audio",
            "score":
            audio_score,
            "ratio":
            [audio_total -
             audio_good_total, audio_good_total] if audio_score else [],
            "present":
            not not audios
        }, {
            "name": "zoom",
            "score": zoom_score,
            "ratio": [],
            "present": True
        }]
    }
Exemplo n.º 3
0
def like_on_page(link):
    driver.get(link)
    try:
        like = driver.find_element_by_xpath("//a[@onclick='return ajax.click(this, Like);']")
        like.click()
    except:
        debug_screenshot("VK_like_on_page_")
Exemplo n.º 4
0
def checker_2_4(url):
    driver.get(url)
    title_elem = driver.find_element_by_css_selector("title")
    title_score = 1 if title_elem else 0

    links = driver.find_elements_by_css_selector("a")

    links_total = len(links)
    if links_total:
        good_links_total = sum([1 for link in links if link.text])
    link_score = good_links_total / links_total  if links_total else 1

    return {
        "total_score": (title_score + link_score) / 2,
        "subs": [
            {
                "name": "title",
                "score": title_score,
                "ratio": [],
                "present": True
            },
            {
                "name": "link",
                "score": link_score,
                "ratio": [links_total - good_links_total, good_links_total] if links_total else [],
                "present": not not links_total
            }
        ]
    }
Exemplo n.º 5
0
def join_group(link):  #work
    driver.get(link)
    try:
        join = driver.find_element_by_xpath("//a[@class='button wide_button']")
        join.click()
    except:
        debug_screenshot("VK_join_group_")
Exemplo n.º 6
0
def twit_login():
    driver.get("https://twitter.com/login")
    sleep(1)
    try:
        text_area = driver.find_element_by_xpath(
            "/html/body/div[1]/div[2]/div/div/div[1]/form/fieldset/div[1]/input"
        )
        text_area.send_keys(TWIT_LOGIN)

        text_area = driver.find_element_by_xpath(
            "/html/body/div[1]/div[2]/div/div/div[1]/form/fieldset/div[2]/input"
        )
        text_area.send_keys(TWIT_PASSWORD)

        submit = driver.find_element_by_xpath("//button[@type='submit']")
        submit.click()
    except:
        text_area = driver.find_element_by_xpath(
            "//input[@name='session[username_or_email]']")
        text_area.send_keys(TWIT_LOGIN)

        text_area = driver.find_element_by_xpath(
            "//input[@name='session[password]']")
        text_area.send_keys(TWIT_PASSWORD)

        submit = driver.find_element_by_xpath("//div[text()='Войти']")
        submit.click()
Exemplo n.º 7
0
def checker_4_1(url):
    checker_url = "https://validator.w3.org/check?" + parse.urlencode(
        {"uri": url})
    driver.get(checker_url)

    valid_result = driver.find_elements_by_css_selector(".valid")
    is_valid = not not valid_result
    return {"total_score": 1 if is_valid else 0, "subs": []}
Exemplo n.º 8
0
 def login(self):
     driver.get(URL_LOGIN)
     driver.find_element_by_id("Client.UserName").send_keys("elisa")
     driver.find_element_by_id("Client.Password").send_keys("GGI")
     driver.find_element_by_xpath(
         "//*[@class='button' and @value='Login']").click()
     wait = WebDriverWait(driver, 5)
     element = wait.until(
         EC.presence_of_element_located((By.CLASS_NAME, "categories")))
Exemplo n.º 9
0
def like_on_page(link):
    try:
        driver.get(link)
        page = driver.find_element_by_xpath(
            "/html/body/div[1]/div[3]/div[1]/div/div/div[2]/div[1]/div/div[2]/div/div[1]/div/div/div[1]/button"
        )
        page.click()
    except:
        debug_screenshot("FB_like_on_page_")
Exemplo n.º 10
0
def target_login():
    driver.get("https://vktarget.ru")
    text_area = driver.find_element_by_name("username")
    text_area.send_keys(TARGET_LOGIN)

    text_area = driver.find_element_by_name("password")
    text_area.send_keys(TARGET_PASSWORD)

    submit = driver.find_element_by_xpath("//div[@data-login='******']")
    submit.click()
Exemplo n.º 11
0
def fb_login():
    driver.get("https://www.facebook.com")
    text_area = driver.find_element_by_name('email')
    text_area.send_keys(FB_LOGIN)

    text_area = driver.find_element_by_name('pass')
    text_area.send_keys(FB_PASSWORD)

    submit = driver.find_element_by_id('loginbutton')
    submit.click()
Exemplo n.º 12
0
def vk_login():
    driver.get("https://m.vk.com/")
    text_area = driver.find_element_by_name('email')
    text_area.send_keys(VK_LOGIN)

    text_area = driver.find_element_by_name('pass')
    text_area.send_keys(VK_PASSWORD)

    submit = driver.find_element_by_class_name("fi_row_new")
    submit.click()
Exemplo n.º 13
0
def checker_2_3(url):
    driver.get(url)
    all_elements = driver.find_elements_by_css_selector("*")
    has_flash = False
    for elem in all_elements:
        duration = elem.value_of_css_property("animation-duration")[:-1]
        if float(duration) * 3 < 1:
            has_flash = True

    return {"total_score": 0 if has_flash else 1, "subs": []}
Exemplo n.º 14
0
def retweet_post(link):
    try:
        driver.get(link)
        button = driver.find_elements_by_xpath(
            '//button[@data-modal="ProfileTweet-retweet"]')
        button[0].click()
        button = driver.find_elements_by_xpath(
            "/html/body/div[24]/div/div[2]/form/div[2]/div[3]/button")
        button[0].click()
    except:
        debug_screenshot("TWITTER_retweet_post_")
Exemplo n.º 15
0
def get_js(url):
    driver.get(url)
    js = [
        script.get_attribute("innerHTML")
        for script in driver.find_elements_by_tag_name("script")
        if "eval" in script.get_attribute("innerHTML")
    ][0]
    beautified_js = jsbeautifier.beautify(js)
    if is_alive(driver):
        driver.quit()

    return beautified_js
Exemplo n.º 16
0
def subscribe_account(link):
    try:
        driver.get(link)
        sleep(2)
        try:
            button = driver.find_element_by_xpath("//*[text()='Follow']")
        except:
            button = driver.find_element_by_xpath("//*[text()='Читать']")
        button.click()
        sleep(1)
    except:
        debug_screenshot("TWITTER_subscribe_account_")
Exemplo n.º 17
0
def checker_1_2(url):
    driver.get(url)

    # objects = driver.find_elements_by_css_selector("object")
    # object_total = len(objects)
    # object_good_total = 0
    # for obj in objects:
    #     if obj.find_element_by_css_selector("p") or obj.find_element_by_css_selector("object"):
    #         object_good_total+=1

    # total_score = object_good_total / object_total if object_total > 0 else 1

    audios = driver.find_elements_by_css_selector("audio")

    audios_total = len(audios)
    audio_good_total = 0
    for s in audios:
        if len(
                s.find_elements_by_css_selector("[aria-label]")
                and len(s.find_elements_by_css_selector("track"))):
            audio_good_total += 1

    videos = driver.find_elements_by_css_selector("video")
    videos_total = len(videos)
    videos_good_total = 0
    for s in audios:
        if len(s.find_elements_by_css_selector("[aria-label]")):
            videos_good_total += 1

    total = audios_total + audios_total

    return {
        "total_score":
        (videos_good_total + audio_good_total) / total if total > 0 else 1,
        "subs": [{
            "name":
            "audio",
            "score":
            audio_good_total / audios_total if audios_total != 0 else 1,
            "ratio": [audios_total - audio_good_total, audio_good_total],
            "present":
            audios_total > 0
        }, {
            "name":
            "video",
            "score":
            videos_good_total / videos_total if videos_total != 0 else 1,
            "ratio": [videos_total - videos_good_total, videos_good_total],
            "present":
            videos_total > 0
        }]
    }
Exemplo n.º 18
0
def check_profit():
    i = 1
    driver.get("https://vktarget.ru/list/")
    while True:
        try:
            xpath = str("/html/body/div[22]/div/div[3]/div[7]/div[" + str(i) +
                        "]/div[6]")
            button = driver.find_element_by_xpath(xpath)
            sleep(random.uniform(2, 10))  # pause for stop yorzat'
            button.click()
            i += 1
        except selenium.common.exceptions.NoSuchElementException:
            break
Exemplo n.º 19
0
def render_all_logo_templates():
    for page in range(1, 5):
        for template_index in range(15):
            driver.get(
                URL + '/' + str(page) +
                '?filters%5Bcategory%5D=3&sort%5Bfield%5D=&filters%5Bname%5D=&filters%5Btag%5D='
            )

            templates = driver.find_elements_by_css_selector(
                'body > div.pusher > div.ui.container > div.ui.three.stackable.grid.template-list > div > div > div.preview.template-card'
            )

            click(templates[template_index])
            time.sleep(4)

            click('a[href*="/new"]')
            time.sleep(4)

            total_categories = len(
                driver.find_elements_by_css_selector(
                    'body > div.pusher > header > div.ui.fluid.second-header.container.customize-container > div > div > a'
                ))

            for i in range(total_categories):
                current_category = driver.find_element_by_css_selector(
                    'a.item.active').text
                if (current_category == 'Texts'):
                    texts = driver.find_elements_by_css_selector(
                        'input[name*="render[texts]"]')
                    for index, text in enumerate(texts):
                        key(text, f"(Text #{index + 1})")
                    click('a[title="Next Step"]')
                elif (current_category == 'Colors'):
                    click('a[title="Next Step"]')
                elif (current_category == 'Images'):
                    images = driver.find_elements_by_css_selector(
                        'input[name*="render[images]"]')
                    for image in images:
                        key(
                            image,
                            '/Users/simon/Dev/viddyoze-bot/assets/logo-black.png'
                        )
                    click('a[title="Next Step"]')
                elif (current_category == 'Create'):
                    click("//*[contains(text(), 'Create Your Video')]")
                time.sleep(4)

            print('Rendering...')

            wait = WebDriverWait(driver, 60 * 60 * 24)
            wait.until(lambda driver: "/download" in driver.current_url)
Exemplo n.º 20
0
def insta_login():
    driver.get("https://www.instagram.com/accounts/login/")
    sleep(3)
    text_area = driver.find_element_by_name("username")
    text_area.send_keys(INSTA_LOGIN)

    text_area = driver.find_element_by_name('password')
    text_area.send_keys(INSTA_PASSWORD)

    submit = driver.find_element_by_xpath(
        "/html/body/span/section/main/div/article/div/div[1]/div/form/span/button"
    )
    submit.click()
    sleep(2)
Exemplo n.º 21
0
def render_template_by_name(name, webpage, logo_path):
    driver.get(URL + '?filters%5Bname%5D=' + name.replace(' ', '+'))

    template = driver.find_element_by_css_selector(
        'body > div.pusher > div.ui.container > div.ui.three.stackable.grid.template-list > div > div > div.preview.template-card'
    )

    click(template)
    time.sleep(4)

    click('a[href*="/new"]')
    time.sleep(4)

    total_categories = len(
        driver.find_elements_by_css_selector(
            'body > div.pusher > header > div.ui.fluid.second-header.container.customize-container > div > div > a'
        ))

    print('Total Categories: ' + str(total_categories))
    for _ in range(total_categories):
        current_category = driver.find_element_by_css_selector(
            'a.item.active.hovered').text
        print(current_category)
        if (current_category == 'Texts'):
            texts = driver.find_elements_by_css_selector(
                'input[name*="render[texts]"]')
            print(texts)
            for text in texts:
                key(text, webpage)
            click('a[title="Next Step"]')
        elif (current_category == 'Colors'):
            click('a[title="Next Step"]')
        elif (current_category == 'Images'):
            images = driver.find_elements_by_css_selector(
                'input[name*="render[images]"]')
            for image in images:
                key(image, os.getcwd() + '/' + logo_path)
            click('a[title="Next Step"]')
        elif (current_category == 'Create'):
            click("//*[contains(text(), 'Create Your Video')]")
        time.sleep(4)

    print('Rendering...')

    wait = WebDriverWait(driver, 60 * 60 * 24)
    wait.until(lambda driver: "/download" in driver.current_url)

    wait_for_download(os.getcwd() + '/renders')
Exemplo n.º 22
0
def user_login(username, password):
    driver.get("http://instagram.com")
    time.sleep(5)
    username_loc = driver.find_element_by_xpath("//input[@name='username']")
    password_loc = driver.find_element_by_xpath("//input[@name='password']")
    login_button = driver.find_element_by_xpath("//div/button/div[text()='Log In']")
    username_loc.send_keys(username)
    password_loc.send_keys(password)
    login_button.click()
    time.sleep(5)
    dismiss_elem_loc = driver.find_element_by_xpath("//button[text()='Not Now']")
    dismiss_elem_loc.click()
    time.sleep(5)
    notification_elem_loc = driver.find_element_by_xpath("//button[text()='Not Now']")
    notification_elem_loc.click()
    time.sleep(10)
Exemplo n.º 23
0
def checker_1_3(url):
    driver.get(url)

    roles = driver.find_elements_by_css_selector("[role]")
    role_score = 1 if len(roles) else 0
    heading = driver.find_elements_by_css_selector("[role=heading]")
    heading_score = 1 if len(heading) else 0
    aria_score = None
    aria_total = None
    if roles:
        good_aria_totoal = sum([
            1 for elem in roles if elem.get_attribute("aria-labelledby")
            or elem.get_attribute("aria-describedby")
        ])
        aria_total = len(roles)
        aria_score = good_aria_totoal / aria_total
    else:
        aria_score = 1

    return {
        "total_score": (role_score + heading_score + aria_score) / 3,
        "subs": [
            {
                "name": "role_score",
                "score": role_score,
                "ratio": [],
                "present": not not roles
            },
            {
                "name": "heading_score",
                "score": heading_score,
                "ratio": [],
                "present": not not roles
            },
            {
                "name":
                "aria_score",
                "score":
                aria_score,
                "ratio":
                [aria_total -
                 good_aria_totoal, good_aria_totoal] if aria_total else [],
                "present":
                not not roles
            },
        ]
    }
Exemplo n.º 24
0
def get_task_list():  # parse target for all tasks
    driver.get("https://vktarget.ru/list/")
    sleep(5)  # ВАЖНО
    html = driver.execute_script(
        "return document.getElementsByTagName('html')[0].innerHTML")
    task_list = re.findall(
        r'<a rel="nofollow noopener" data-bind="url" target="_blank" href=".{1,128}</a>',
        html)
    if not task_list:
        sleep(10)
        html = driver.execute_script(
            "return document.getElementsByTagName('html')[0].innerHTML")
        task_list = re.findall(
            r'<a rel="nofollow noopener" data-bind="url" target="_blank" href=".{1,128}</a>',
            html)
    # TODO:
    print(task_list)
    return task_list
Exemplo n.º 25
0
def checker_2_1(url):
    driver.get(url)
    start_element = driver.switch_to_active_element()
    body_elem = driver.find_element_by_css_selector("body")
    counter = 0
    has_trap = True
    while counter < 1000:
        body_elem.send_keys(Keys.TAB)
        if driver.switch_to_active_element() != start_element:
            has_trap = False
            break
        else:
            counter+=1

    return {
        "total_score":0 if has_trap else 1,
        "subs":[]
    }
Exemplo n.º 26
0
def get_shows(url, show_type="shows", verbose=True):
    driver.get(url)
    show_url_map = []
    shows = driver.find_element_by_id(show_type)
    iterator = tqdm(enumerate(
        shows.find_elements_by_class_name("box-content")),
                    desc="Extracting shows") if verbose else enumerate(
                        shows.find_elements_by_class_name("box-content"))
    for i, show in iterator:
        if i == 0:
            continue
        try:
            show_section = show.find_element_by_xpath(".//*")
            show_name = show_section.text
            show_url = show_section.get_attribute("href")
            if len(show_name) > 1:
                show_url_map.append((show_name, show_url))
        except:
            pass
    return dict(show_url_map)
Exemplo n.º 27
0
def checker_2_2(url):
    driver.get(url)
    forms = driver.find_elements_by_css_selector("form")
    forms_total = len(forms)
    if forms_total:
        good_forms_total = sum([1 for form in forms if form.find_elements_by_css_selector("[type=submit]")])
        form_enough_time_score = good_forms_total / forms_total
    else:
        form_enough_time_score = 1

    return {
        "total_score":(form_enough_time_score) / 1,
        "subs":[
            {
                "name": "form",
                "score": form_enough_time_score,
                "ratio": [forms_total - good_forms_total, good_forms_total] if forms_total else [],
                "present": not not forms
            }
        ]
    }
Exemplo n.º 28
0
 def get_products_and_save_to_db(category_id):
     link_to_products_page = URL_PRODUCT_LISTING+"RPP=1000&P=1&CID="+str(category_id)+"&IDS=&QTY="
     #"https://towneshops.directedje.com/Galardi/product-listing.asp?RPP=1000&P=1&CID=583&IDS=&QTY="
     try:
         driver.get(link_to_products_page)
     except TimeoutException:
         driver.execute_script("window.stop();")
     products_elements = driver.find_elements_by_xpath("//table[@class='productlisting']//child::tr")
     products = []
     for product_element in products_elements:
         try:
             temp = product_element.text.split("\n")
             product_id = temp[0]
             product_name = r'{}'.format(temp[2])
             available = temp[4].split(" ")[0] if "Available" in temp[4] else 0
             description = '{}'.format(temp[3])                
             try:
                 image_url = product_element.find_element_by_class_name('thickbox').get_attribute('href')
                 image_name = image_url.split("/")[-1]
             except Exception as e:
                 image_url = ""
                 image_name = ""
             # save image to images
             new_product = Product(product_id, product_name, available, image_name, image_url, category_id, description)
             products.append(new_product)
             database.insert_product(new_product.product_id,
                                     new_product.product_name,
                                     new_product.available,
                                     new_product.image_name,
                                     new_product.image_url,
                                     new_product.category_id,
                                     new_product.description)
         except Exception as e:
             print("error creating product : "+str(e))
     print("Finish insert products for category_id : "+str(category_id))
     return products
Exemplo n.º 29
0
from driver import driver
import os

USER = os.getenv('USER')
PASSWORD = os.getenv('PASSWORD')

driver.get('https://www.instagram.com/')
username = driver.find_element_by_name('username')
username.clear()
username.send_keys(USER)
password = driver.find_element_by_name('password')
password.clear()
password.send_keys(PASSWORD)
login = driver.find_element_by_css_selector("button.sqdOP.L3NKy.y3zKF")
login.click()
from driver import driver, Keys

driver.get("http://*****:*****@id="task-2"]/div[1]/div/span')
txt0 = Today0.text
print("first task found: " + txt0)
Today1 = driver.find_element_by_xpath('//*[@id="task-1"]/div[1]/div/span')
txt1 = Today1.text
print("second task found: " + txt1)

#placeholder so window doesnt close
test = input("press enter when done")