Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function LoginJobs($browser)
- {
- $browser.navigate("http://jobs.bg/login.php")
- $browser.Visible = $true
- Start-Sleep -Seconds 2
- $doc = $browser.Document
- $mails = $doc.getElementsByName("username")
- foreach($m in $mails)
- {
- $m.value = "user.user@usermail.com"
- }
- $pass = $doc.getElementsByName("password")
- foreach($p in $pass)
- {
- $p.value = "userPass"
- }
- $nobr = $doc.getElementsByTagName("nobr")
- foreach($b in $nobr)
- {
- if($b.innerText -eq 'Вход')
- {
- $b.click()
- }
- }
- }
- function SearchJobs($browser)
- {
- #$browser.fullscreen = $true
- #navigate to search jobs
- $doc = $browser.Document
- $links = $doc.getElementsByTagName("a")
- foreach($a in $links)
- {
- if($a.innerText -eq 'Начало')
- {
- $a.click()
- }
- }
- #select required region
- $region = $doc.getElementsByName('region')
- if($region.item(0).item(23).innerText -match 'Sofia')
- {
- $region.item(0).item(23).selected = $true
- $region.item(0).fireEvent('onchange')
- }
- #select required categories
- $categories = $doc.getElementsByName('l_category[]')
- if($categories.item(0).item(5).innerText -match 'IT')
- {
- $categories.item(0).item(5).selected = $true
- $categories.item(0).fireEvent('onchange')
- Start-Sleep -Seconds 0.5
- }
- if( $categories.item(0).item(3).innerText -match 'Software')
- {
- $categories.item(0).item(3).selected = $true
- $categories.item(0).fireEvent('onchange')
- Start-Sleep -Seconds 0.5
- }
- if( $categories.item(0).item(6).innerText -match 'QA')
- {
- $categories.item(0).item(6).selected = $true
- $categories.item(0).fireEvent('onchange')
- Start-Sleep -Seconds 0.5
- }
- if( $categories.item(0).item(9).innerText -match 'Quality')
- {
- $categories.item(0).item(9).selected = $true
- $categories.item(0).fireEvent('onchange')
- Start-Sleep -Seconds 0.5
- }
- if( $categories.item(0).item(11).innerText -match 'IT Administration')
- {
- $categories.item(0).item(11).selected = $true
- $categories.item(0).fireEvent('onchange')
- Start-Sleep -Seconds 0.5
- }
- if( $categories.item(0).item(17).innerText -match 'IT Quality')
- {
- $categories.item(0).item(17).selected = $true
- $categories.item(0).fireEvent('onchange')
- Start-Sleep -Seconds 0.5
- }
- #select position Level
- $positionLevel = $doc.getElementsByName('position_level[]')
- $positionLevel.item(2).checked = $true
- Start-Sleep -Seconds 0.5
- #select job Type
- $jobType = $doc.getElementsByName('job_type')
- $jobType.item(0).checked = $true
- Start-Sleep -Seconds 0.5
- #select agency FREE Type
- $companyType = $doc.getElementsByName('company_type[]')
- $companyType.item(0).checked = $true
- Start-Sleep -Seconds 1
- $companyType.item(1).checked = $true
- #select job Hours FULL DAY
- $jobHours = $doc.getElementsByName('job_hours')
- $jobHours.item(0).checked = $true
- #search btn
- $searchBtn = $doc.getElementsByTagName('nobr')
- if($searchBtn.item(0).innerText -match 'Търсене')
- {
- $searchBtn.item(0).click()
- }
- }
- function CrawlJobLinks($pageLink, $callsCounter)
- {
- $lastie = $null
- $lastie = new-object -com "InternetExplorer.Application"
- $lastie.navigate($pageLink)
- $lastie.visible = $true
- Start-Sleep -Seconds 2
- $lastiedoc = $lastie.document
- #select results FROM LAST LOGIN - must not do it more than once
- if($callsCounter -le 1)
- {
- $lastLogin = $lastiedoc.getElementsByName('last')
- if($lastLogin.item(0).item(1).innertext -match 'От последното влизане')
- {
- $lastLogin.item(0).item(1).selected =$true
- $lastLogin.item(0).fireEvent('onchange')
- }
- Start-Sleep -Seconds 2
- }
- $jobLinks = $lastiedoc.getElementsByTagName('a') |where ClassName -match 'MainLinkBold' | select -Property href
- #check if we have atleast one page with jobs
- if($jobLinks -ne $null)
- {
- for($i = 1; $i -le $jobLinks.Length - 1; $i++)
- {
- $nextlink = ""
- $nextLink = $jobLinks[$i].href.ToString()
- $br = new-object -com "InternetExplorer.Application"
- $br.visible = $true
- $br.fullscreen= $true
- $br.navigate($nextLink)
- Start-Sleep -Seconds 2
- $dc = $br.Document
- $aList = $dc.getElementsByTagName("a")
- foreach($at in $aList)
- {
- #check for 'apply via linkedin' link
- #if($at.innerText -match "Кандидатствай с LinkedIn")
- #{
- # $at.click()
- # ApplyViaLinkedIn -browser $br
- # break
- #}
- #logic for CV
- if($at.innerText -match "Кандидатствай по тази обява")
- {
- $at.click()
- ApplyViaCV -browser $br
- }
- }
- #set back to zero
- $reqs = $null
- $str = $null
- $nextLink = $null
- $job = $null
- Start-Sleep -Seconds 2
- $success = $dc.getElementsByTagName('b')
- foreach($s in $success.item(0))
- {
- if($s.innerText -match 'Вашето CV беше изпратено успешно.')
- {
- $br.Quit()
- }
- else{
- $br.Quit()
- $br.visible = $true
- }
- }
- }
- #check if there are more than one page with jobs
- $pages = ''
- $pages = $lastiedoc.getElementsByTagName('a') | where ClassName -match 'pathlink' | select
- if($pages -ne $null)
- {
- #recursion bottom
- #divide length because keep-alive session windows affects pages number
- if($pages.Length / 2 -ne $callsCounter)
- {
- $callsCounter++
- $gotoNextPage = ''
- $dummyCounter = $callsCounter + 1
- $callsCounterStr = $dummyCounter.ToString()
- foreach($p in $pages)
- {
- if($p.innerText -eq $callsCounterStr)
- {
- $p.click()
- Start-Sleep -Seconds 2
- $gotoNextPage = $lastie.LocationURL.ToString()
- }
- }
- #done by recursion
- CrawlJobLinks -pageLink $gotoNextPage -callsCounter $callsCounter
- }
- else{
- $ie.Quit()
- $br.Quit()
- }
- }
- }
- }
- function ApplyViaLinkedIn($browser)
- {
- $dc = $browser.Document
- #check for education
- $education = ""
- Start-Sleep -Seconds 3
- $education = $dc.getElementById("education_level_sid")
- if($education -ne $null)
- {
- $bakalavur = $education.all.item(4)
- $bakalavur.selected = $true
- $education.FireEvent('onchange', 1)
- Start-Sleep -Seconds 3
- $in = $dc.getElementsByTagName('a') | where Id -Match 'li_ui_li_gen_' | select
- $in.click()
- #wait for popup
- Start-Sleep -Seconds 3
- $iframe = $dc.getElementsByTagName("iframe") | where Id -Match 'easyXDM_IN_Lib_li_gen_' | select
- $fd = $iframe.document
- $fd > 'C:\Users\User\Desktop\wtf.txt'
- $signInBtn = $fd.getElementsByTagName('a') | where Class -Match 'btn-new-primary IN-signin' | select
- }
- }
- function ApplyViaCV($browser)
- {
- $dc = $browser.Document
- Start-Sleep -Seconds 3
- #set education
- $education = $dc.getElementsByName("education_level_sid")
- if($education -ne $null)
- {
- $education.item(0).item(4).selected = $true
- }
- #add cv file
- $cv = $dc.getElementsByName("file1")
- if($cv -ne $null)
- {
- foreach($f in $cv.item(0))
- {
- if($f.innerText -match 'CV User-EN.pdf')
- {
- $f.selected = $true
- }
- }
- #$cv.FireEvent('onchange', 1)
- }
- #add motivation letter
- $ml = $dc.getElementsByName("file2")
- if($ml -ne $null)
- {
- foreach($f in $ml.item(0))
- {
- if($f.innerText -match 'User Cover letter.doc')
- {
- $f.selected = $true
- }
- }
- }
- #add company msg
- $msgStr = "Dear ... Team,
- I consider myself to be the right person and I would like to apply for the current position if given opportunity.
- Best regards,
- User User."
- $msgSubject = $dc.getElementsByName("subject")
- if($msgSubject -ne $null)
- {
- if($msgSubject.item(0).value -eq $null)
- {
- $msgSubject.item(0).value = "Dear .... Team"
- }
- $msgArea = $dc.getElementsByName("comment")
- $msgArea.item(0).value = $msgStr
- }
- #click Apply
- $applyBtn = $dc.getElementsByTagName('nobr')
- $applyBtn.item(0).click()
- }
- #keep the session 'alive'
- $ie = new-object -com "InternetExplorer.Application"
- LoginJobs -browser $ie
- $jobsURL = 'http://www.jobs.bg/'
- #navigate to search new jobs with same predefined search criteria FROM last user login
- SearchJobs -browser $ie
- Start-Sleep -Seconds 1
- #counter used for the recursion bottom
- $callsCounter = 0
- CrawlJobLinks -pageLink $ie.LocationURL.ToString() -callsCounter $callsCounter
- $ie.quit()
- #
- #linkedin support
- #
- $inbrowser = New-Object -com "InternetExplorer.Application"
- $inbrowser.Visible = $true
- $inbrowser.Navigate('https://www.linkedin.com/uas/connect/user-signin?session_redirect=http%3A%2F%2Fwww%2Elinkedin%2Ecom%2Fcws%2Flogin-popup')
- $indoc = $inbrowser.Document
- $inMail = $indoc.getElementById('session_key-connectLoginForm')
- $inMail.value = 'user.user@gmail.com'
- $inpass = $indoc.getElementById('session_password-connectLoginForm')
- $inpass.value = 'userpass'
- $inBtn = $indoc.getElementsByName('signin') | where value -EQ 'Sign In' | select -First 1
- $inBtn.click()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement