How to use as_not method in Selene

Best Python code snippet using selene_python

app.py

Source:app.py Github

copy

Full Screen

1import gspread2from oauth2client.service_account import ServiceAccountCredentials3from selenium import webdriver4from selenium.webdriver.common.keys import Keys5import time6from selenium.webdriver import ChromeOptions7# https://www.youtube.com/watch?v=cnPlKLEGR7E8scope = [9 "https://spreadsheets.google.com/feeds",10 "https://www.googleapis.com/auth/spreadsheets",11 "https://www.googleapis.com/auth/drive.file",12 "https://www.googleapis.com/auth/drive",13]14creds = ServiceAccountCredentials.from_json_keyfile_name("./creds.json", scope)15client = gspread.authorize(creds)16sheet = client.open("jobSearchTwo").sheet117sheet.clear()18# makes class19class IndeedBot:20 # init21 def __init__(self):22 opts = ChromeOptions()23 opts.add_experimental_option("detach", True)24 # self.bot = webdriver.Chrome("./chromedriver/chromedriver.exe")25 self.bot = webdriver.Chrome()26 # executes search, copies up to 50 urls to global variable links27 def findJobs(self):28 bot = self.bot29 jobs = list()30 global links31 links = list()32 # run once33 # url = "https://www.indeed.com/jobs?as_and=web+developer+javascript&as_phr=&as_any=&as_not=&as_ttl=junior&as_cmp=&jt=all&st=&as_src=&salary=&radius=25&l=United+States&fromage=3&limit=50&sort=date&psf=advsrch&from=advancedsearch"34 # url = "https://www.indeed.com/jobs?as_and=web+developer+javascript&as_phr=&as_any=&as_not=&as_ttl=associate&as_cmp=&jt=all&st=&as_src=&salary=&radius=25&l=United+States&fromage=3&limit=50&sort=date&psf=advsrch&from=advancedsearch"35 url = "https://www.indeed.com/jobs?as_and=software+engineer&as_phr=&as_any=&as_not=&as_ttl=junior&as_cmp=&jt=all&st=&as_src=&salary=&radius=25&l=United+States&fromage=3&limit=50&sort=date&psf=advsrch&from=advancedsearch"36 # https://www.indeed.com/jobs?as_and=web+developer+remote&as_phr=&as_any=&as_not=&as_ttl=&as_cmp=&jt=all&st=&as_src=&salary=&radius=25&l=&fromage=1&limit=50&sort=&psf=advsrch&from=advancedsearch37 # https://www.indeed.com/jobs?as_and=web+developer+title%3Aremote&jt=all&fromage=1&limit=50&psf=advsrch&from=advancedsearch38 # https://www.indeed.com/jobs?q=web+developer+title%3Ajunior&limit=50&fromage=1&radius=25&start=0&l=Chicago%2C+IL39 # https://www.indeed.com/jobs?as_and=web+developer+javascript&as_phr=&as_any=&as_not=&as_ttl=junior&as_cmp=&jt=all&st=&as_src=&salary=&radius=25&l=United+States&fromage=3&limit=50&sort=date&psf=advsrch&from=advancedsearch40 bot.get(url)41 time.sleep(10)42 # finds all titles43 jobs = bot.find_elements_by_class_name("jobtitle")44 # saves href values from all titles45 links = [elem.get_attribute("href") for elem in jobs]46 # find the jobs that can be applied to directly from indeed47 def sortByApplyType(self):48 bot = self.bot49 global links50 global sheet51 count = 052 # enumerates over links53 for idx, link in enumerate(links):54 # goes to link55 bot.get(link)56 time.sleep(5)57 # adds link to first column of sheet58 sheet.update_cell(idx + 1, 1, link)59 # gets values from job ad60 jobName = bot.find_element_by_class_name(61 "jobsearch-JobInfoHeader-title"62 ).text63 jobCompany = bot.find_element_by_css_selector(64 ".jobsearch-InlineCompanyRating > div:first-of-type"65 ).text66 jobLocation = bot.find_element_by_css_selector(67 ".jobsearch-InlineCompanyRating > div:last-of-type"68 ).text69 # saves values to clumns in sheets70 sheet.update_cell(idx + 1, 3, jobName)71 sheet.update_cell(idx + 1, 4, jobCompany)72 sheet.update_cell(idx + 1, 5, jobLocation)73 try: # try quick apply button74 print("clicking apply button")75 # clicks on button76 bot.execute_script(77 'document.querySelector(".jobsearch-IndeedApplyButton-contentWrapper").click();'78 )79 print("saved to list")80 # updates sheet for job as instant-apply81 sheet.update_cell(idx + 1, 2, "insta-apply")82 time.sleep(1)83 # open new blank tab84 count += 185 bot.execute_script("window.open();")86 # switch to the new window which is second in window_handles array87 bot.switch_to_window(bot.window_handles[count])88 except:89 # if click event fails, adds no to instant-apply column in sheet90 print("no button")91 sheet.update_cell(idx + 1, 2, "no")92ethan = IndeedBot()93# gets urls from search results94ethan.findJobs()95# goes through each url and saves info to row in sheets...

Full Screen

Full Screen

indeed.py

Source:indeed.py Github

copy

Full Screen

1#!/usr/bin/python2# -*- coding: utf-8 -*-3import sys, re4from urllib import urlencode,urlopen5AGE = 60 or 'any'6AGE = 607DIST = 158LIMIT = 109SWISS = ['Genève, GE', 'Genève']10regions = ['Paris', 'Rhône-Alpes', 'Essonnes', 'Essonne', 'Lyon', 'Grenoble', 'Genève, GE', 'Annemasse', 'Chambéry', 'Annecy']11postes = ['ingénieur logiciel', 'software engineer', 'développeur', 'devops', 'ingénieur de production']12entreprises = ['CERN', 'CEA', 'INRIA', 'CNRS']13domaines = ['Carte à puce', 'Smartcard', 'Laboratoire']14words = ['python', 'django', 'angular', 'bootstrap', 'responsive']15keywords = postes + [''] + entreprises + [''] + domaines + [''] + words16def build_search_url(**args):17 '''http://www.indeed.fr/emplois?as_and=&as_phr=&as_any=&as_not=&as_ttl=&as_cmp=&jt=all&st=&radius=50&l=Paris&fromage=15&limit=50&sort=date&psf=advsrch'''18 args['as_and'] = args.get('as_and','')19 args['as_phr'] = args.get('as_phr','')20 args['as_any'] = args.get('as_any','')21 args['as_not'] = args.get('as_not','')22 args['as_ttl'] = args.get('as_ttl','')23 args['as_cmp'] = args.get('as_cmp','')24 args['jt'] = args.get('jt','all') # job type25 args['st'] = args.get('st','')26 args['radius'] = args.get('radius',DIST)27 args['l'] = args.get('l','')28 args['fromage'] = args.get('fromage',AGE)29 args['limit'] = args.get('limit',LIMIT)30 args['sort'] = args.get('sort','date')31 args['psf'] = args.get('psf','advsrch')32 33 if args['l'] in SWISS:34 url = 'http://www.indeed.ch/Stellen?'35 else:36 url = 'http://www.indeed.fr/emplois?'37 38 try:39 url += urlencode(args)40 except:41 print args42 raise43 44 # print url45 return url46 47def query(all='', any='', exact='', no='', l='Paris', r=DIST, t=AGE):48 url = build_search_url(as_and=all, as_any=any, as_not=no, l=l, radius=r, fromage=t)49 page = urlopen(url).read()50 51 if l in SWISS:52 pattern = '<div id="searchCount">Stellen (.*) - (.*) von (.*)</div>'53 else:54 pattern = '<div id="searchCount">Emplois (.*) à (.*) sur (.*)</div>'55 m = re.search(pattern, page)56 57 if not m:58 return 059 else:60 n,tot,max = m.group(1).replace('\xc2\xa0',''),m.group(2).replace('\xc2\xa0',''),m.group(3).replace('\xc2\xa0','')61 # print n, tot, max62 63 if int(tot) == LIMIT:64 return max65 else:66 return tot67 68# print query("python",l="Genève")69# sys.exit(0)70# for r in regions:71# for r in ['Fontainebleau']:72# print '\n',r73# for k in keywords:74# print query(k, l=r) if k else '\''75# print query('ingénieur', any="python django", t=30)76# print query('ingénieur', any="django", no="python", t=30)77# print query('ingénieur', any="python django", no="django", t=30)78# print query('ingénieur', any="python", no="django", t=30)79# print query('', any="ingénieur python", no="django", t=30)80# print query('ingénieur python', t=30)81# print query('ingénieur django', t=30)82# print query('ingénieur python django', t=30)83# print query("django")84# print query("python")85# print query("python django")86# print query(any="python django")87# print query("django", no="python")88# print query("django")89# print query("python")90### DISTANCES Vol d'oiseau ###91# Annecy-Genève ou Annemasse 3392# Annecy-Gex 4793# Annecy-Chambéry 4094# Chambéry-Aix les bains 1395# Chambéry-Grenoble 46 (49 d'après indeed)96# Chambéry-Genève 7497# Chambéry-Gex 8698# Chambéry-Lyon 8699# Grenoble-Lyon 94100# Grenoble-Genève 119101# Lyon-Genève 112102# Lyon-Chalon 112103# Lyon-Valence 92104# Lyon-Clermont 135105# Versailles-Paris 17106# Palaiseau-Versailles 13107# Palaiseau-Evry 17108# Evry-Arpajon 14109# Evry-Melun 19110# Melun-Fontainebleau 16111### RECHERCHES ###112# Très Large : Lyon 120 Km113# Large : Chambéry 75-80 Km114# Ciblée: Grenoble 25, Chambéry 25, Annemasse 30? ou Annecy 20, Annemasse 20115#### Popularité des technos :116# Bootstrap, angularjs, backbonejs, web components, rails, django, symphony2,117# print query("python", l="Chambéry", t=60, r=49)118# print query("python", l="Chambéry", t=60, r=10)119# print query("python", l="Grenoble", t=60, r=10)120# print query("python", l="Aix-les-Bains", t=60, r=10)121# print query("python", l="Annecy", t=60, r=10)122# print query("python", l="Bourgoin-Jailleu", t=60, r=10)123# print query("python", l="Albertville", t=60, r=10)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Selene automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful