def get_risk_assessments():
    """Open the SHE Assure website, and bulk-download project risk assessments to the local file system."""
    user_profile = os.environ['UserProfile']
    downloads_folder = os.path.join(user_profile, 'Downloads')
    ras_folder = os.path.join(user_profile, 'Documents', 'Safety', 'RAs')
    os.makedirs(ras_folder, exist_ok=True)
    os.chdir(downloads_folder)

    web = webbot.Browser()
    web.go_to('https://uk.sheassure.net/stfc/Risk/ActivityRisk/Page/1')
    wait_for(web, 'Single Sign-On')
    web.click('Microsoft')
    wait_for(web, 'Sign in')
    web.type(username, into='username')
    web.click('Next')
    wait_for(web, 'STFC Federation Service')
    web.type(password, into='password')
    web.click('Sign in')
    wait_for(web, 'Stay signed in?')
    web.click('Yes')
    wait_for(web, 'Activity Risk Assessment')

    paperclip_links = web.find_elements(tag='i', classname='fa-paperclip')
    for i in range(len(paperclip_links)):
        try:
            print(i)
            link = paperclip_links[i]
            link.click()
            # get info about RA
            info = web.find_elements(tag='ul', classname='list_information')[0]
            attributes = [tag.text for tag in info.find_elements_by_tag_name('span')]
            values = [tag.get_attribute('title') for tag in info.find_elements_by_tag_name('a')]
            info_dict = {attribute.rstrip(':'): value for attribute, value in zip(attributes, values)}
            reference_number = info_dict['Reference']
            title = info_dict['Assessment Title'].split('\n')[0]  # just take first line
            title = remove_bad_chars(title).strip()  # remove whitespace from start and end
            attachment_links = web.find_elements(tag='span', classname='fa-file')
            folder_name = f'{reference_number} {title}'
            print(folder_name)
            ra_folder = os.path.join(ras_folder, folder_name)
            os.makedirs(ra_folder, exist_ok=True)
            for attachment in attachment_links:
                parent = attachment.find_element_by_xpath('..')
                filename = parent.text
                print(filename)
                attachment.click()  # download attachment
                for _ in range(30):
                    sleep(1)
                    if os.path.exists(filename):
                        break
                else:
                    raise InformationFetchFailure('Data export not successful')
                os.rename(filename, os.path.join(ra_folder, filename))
        except InformationFetchFailure:
            print("Couldn't fetch attachment")
        finally:
            web.go_back()
            paperclip_links = web.find_elements(tag='i', classname='fa-paperclip')
    web.driver.quit()
def Browser_get_soup(link_base):
    import webbot, time
    from bs4 import BeautifulSoup
    web = webbot.Browser()
    web.go_to(link_base)
    time.sleep(3)
    content = web.get_page_source()  # Saca la código fuente de la página
    soup = BeautifulSoup(
        content, 'html.parser'
    )  # Acá le defino a soup que lo que estoy viendo es un HTML
    return soup
 def ntests_download(self, mode='2'):
     ''' mode = 1 : download tests .csv driving Chrome https://ourworldindata.org 
         mode = 2 : from github https://github.com/owid/covid-19-data/blob/master/public/data/testing/covid-testing-all-observations.csv
     '''
     if mode == 1:
         import webbot, time
         print(
             'covid_analysis_wiki.download_tests(): downloading n.tests using Chromium...'
         )
         # driving Chrome to download:
         driver = webbot.Browser()
         driver.go_to('https://ourworldindata.org/covid-testing')
         driver.scrolly(4000)
         driver.click(text='DATA', number=1)
         driver.click(text=self.ntests_filename)
         timeout = 10
         filesizes = 0
         t0 = time.time()
         # wait until download is done:
         while True:
             time.sleep(.5)
             try:
                 filesize = os.path.getsize('/home/francesco/Downloads/' +
                                            self.ntests_filename)
             except:
                 filesize = 0
             filesizes = np.append(filesizes, filesize)
             if filesize > 0 and len(filesizes) > 3 and not np.any(
                     np.diff(filesizes)[:-3]):
                 break
             else:
                 if time.time() - t0 > timeout:
                     raise TimeoutError('timeout in downlaoding.')
         driver.close_current_tab()
         # mv downloaded file to here:
         os.replace(
             '/home/francesco/Downloads/' + self.ntests_filename,
             '/home/francesco/scripts/repositories/covid19_analysis/' +
             self.ntests_filename)
         print('covid_analysis_wiki.download_tests(): done.')
     elif mode == 2:
         import wget
         wget.download(self.ntests_github)
         self.ntests_filename = 'covid-testing-all-observations.csv'
Esempio n. 4
0
import webbot
import os
import time
import random
os.system('pip3 install pyautogui')
while True:
	driver = webbot.Browser()
	print("")
	driver.go_to('https://kahoot.it/')
	code = '736765'
	input_elements = driver.find_elements(xpath='//input')
	driver.type(driver.Key.TAB,into=input_elements[0].text)
	driver.type(code)
	driver.type(driver.Key.ENTER,into=input_elements[0].text)
	time.sleep(0.2)
	discname1 = ['saucy', 'momma', 'mecha', 'earth', 'barbed', 'prehistoric', 'old','cosmic', 'metallic', 'neat', 'supa', 'haunted', 'ruthless', 'clueless', 'rough', 'killer', 'spooky', 'retro', 'ancient', 'strange', 'astro', 'baren', 'burned', 'chared', 'crap', 'cranky', 'crummy', 'croaked', 'dead', 'daring', 'drunk', 'droopy', 'dank', 'drowned', 'enraged', 'angry', 'good', 'garnished', 'groaning', 'happy', 'hopeful', 'graceful', 'gentle', 'hairy', 'inteligent', 'intergallactic', 'jelly filled', 'jumping', 'kind', 'limp', 'blind', 'lumpy', 'insane', 'meek', 'nocternal', 'artifcial', 'perfect', 'quirky', 'petty', 'rocky', 'sad', 'sorrowful', 'useless', 'sickly', 'unbeatable', 'zesty', 'acrobatic', 'buttered', 'burpy', ]
	noun = ['chair', 'tortoise', 'fruit', 'paper', 'gecko', 'giraffe', 'mountain', 'boy', 'urinal', 'pencil','toenail', 'pug', 'wrangler', 'garbage', 'tugboat', 'bladder', 'viper', 'chicken', 'gnome', 'slayer', 'apple', 'artichoke', 'butter', 'bladder', 'cat', 'coop', 'carp', 'dome', 'door', 'horse', 'dart', 'fart', 'farie', 'garlic', 'goop', 'gunk', 'guild', 'hoop', 'harp', 'handle', 'house', 'cow', 'cake', 'cookie', 'largo', 'armor', 'bow', 'map', 'mayonaise', 'egg', 'napkin', 'octopus', 'park', 'pancake', 'punk', 'queen', 'rock', 'salmon', 'sock', 'syrup', 'tophat', 'viking', 'hipopotomous']
	discname2 = ['saucy', 'momma', 'mecha', 'earth', 'barbed', 'prehistoric', 'old','cosmic', 'metallic', 'neat', 'supa', 'haunted', 'ruthless', 'clueless', 'rough', 'killer', 'spoopy', 'retro', 'ancient', 'strange', 'astro', 'baren', 'burned', 'chared', 'crap', 'cranky', 'crummy', 'croaked', 'dead', 'daring', 'drunk', 'droopy', 'dank', 'drowned', 'enraged', 'angry', 'good', 'garnished', 'groaning', 'happy', 'hopeful', 'graceful', 'gentle', 'hairy', 'inteligent', 'intergallactic', 'jelly filled', 'jumping', 'kind', 'limp', 'blind', 'lumpy', 'insane', 'meek', 'nocternal', 'artifcial', 'perfect', 'quirky', 'petty', 'rocky', 'sad', 'sorrowful', 'useless', 'sickly', 'unbeatable', 'zesty', 'acrobatic', 'buttered', 'burpy',]
	noun2 = ['chair', 'tortoise', 'fruit', 'paper', 'gecko', 'giraffe', 'mountain', 'boy', 'urinal', 'pencil','toenail', 'pug', 'wrangler', 'garbage', 'tugboat', 'bladder', 'viper', 'chicken', 'gnome', 'slayer', 'apple', 'artichoke', 'butter', 'bladder', 'cat', 'coop', 'carp', 'dome', 'door', 'horse', 'dart', 'fart', 'farie', 'garlic', 'goop', 'gunk', 'guild', 'hoop', 'harp', 'handle', 'house', 'cow', 'cake', 'cookie', 'largo', 'armor', 'bow', 'map', 'mayonaise', 'egg', 'napkin', 'octopus', 'park', 'pancake', 'punk', 'queen', 'rock', 'salmon', 'sock', 'syrup', 'tophat', 'viking', 'hipopotomous',]
	rand1 = random.choice(discname1)
	rand2 = random.choice(noun)
	username = (random.choice(discname2) + ' ' + random.choice(discname1) + ' ' + random.choice(noun) + ' ' + random.choice(noun2))
	input_elements = driver.find_elements(xpath='//input')
	driver.type(driver.Key.TAB,into=input_elements[0].text)
	driver.type(username)
	driver.type(driver.Key.ENTER,into=input_elements[0].text)
while True:
  while True:
    url = driver.get_current_url()
    if url == "https://kahoot.it/v2/gameblock":
      break
Esempio n. 5
0
        file_path + "attestation_navigo_{}_{}_{}_{}.pdf".format(
            month, year, first_name, last_name))


def move_pdf(file_path, month, year, first_name, last_name, new_file_path=""):
    if new_file_path != "":
        move(
            file_path + "attestation_navigo_{}_{}_{}_{}.pdf".format(
                month, year, first_name, last_name),
            new_file_path + "attestation_navigo_{}_{}_{}_{}.pdf".format(
                month, year, first_name, last_name))


if __name__ == "__main__":
    date = datetime.now()
    web = webbot.Browser()
    navigo_url = "https://www.jegeremacartenavigo.fr/connexion/connexion"
    username = "******"
    # base64 encoded password
    password = "******"
    first_name = "first_name"
    last_name = "last_name"
    # Default path where files are downloaded in your PC
    file_path = "/home/file/path"
    # Optional path to move file tobelow
    new_file_path = ""

    month_number_name = {
        1: "janvier",
        2: "février",
        3: "mars",
Esempio n. 6
0
# If you don't see the virtual computer running then it's probably running in the background

import webbot
import bruteforce
import time
import stayalive
import os
import threading

bot = webbot.Browser()


def follow(user):
    print(f'Following {user}')
    f = open('following', 'r')
    following = f.read().split('\n')
    f.close()
    for i in following:
        if user == i:
            bot.go_to(f'https://github.com/{user}?tab=following')
            bot.click('Follow', tag="button", multiple=True)
            bot.go_to(f'https://github.com/{user}?tab=followers')
            bot.click('Follow', tag="button", multiple=True)

            return
    bot.go_to(f'https://github.com/{user}')
    bot.click('Follow', tag="button")
    f = open('following', 'a')
    f.write(f"{user}\n")
    f.close()
Esempio n. 7
0
"""
import os

import webbot


def wait_for_and_click(browser, text):
    while not browser.exists(text=text):
        pass
    browser.click(text=text)


LUXMED_LOGIN = os.environ.get("LUXMED_LOGIN", "")
LUXMED_PASS = os.environ.get("LUXMED_PASS", "")

w = webbot.Browser(showWindow=True)
w.go_to("https://portalpacjenta.luxmed.pl/PatientPortal/Account/LogOn")
w.type(LUXMED_LOGIN, id="Login")
w.type(LUXMED_PASS, id="TempPassword")
w.type(LUXMED_PASS, id="Password")
w.click(tag="div", classname="submit")

wait_for_and_click(
    w,
    text="""
            Chcę umówić wizytę lub badanie
        """,
)
wait_for_and_click(w, text="Wizyta w placówce")
wait_for_and_click(w, text="Wybierz usługę")
wait_for_and_click(
Esempio n. 8
0
 def __init__(self):
     self.url = "https://www.studydrive.net/de"
     self.web = webbot.Browser()
     self.delay = 1