-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscrape.py
More file actions
60 lines (44 loc) · 1.76 KB
/
scrape.py
File metadata and controls
60 lines (44 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
import time
class jobInfo:
def __init__(self, jobDescription,companyDescription, title):
self.jobDescription = jobDescription
self.companyDescription = companyDescription
self.title = title
def getInfo(link):
driver = webdriver.Chrome()
driver.get(link)
## FOR JOB INFO
# x button
xbutton = driver.find_elements(By.CLASS_NAME,'modal__dismiss')
for element in xbutton:
if element.aria_role == "button":
element.click()
# job title
t = driver.find_element(By.CLASS_NAME, 'top-card-layout__title').text
# show more
driver.find_element(By.CLASS_NAME, 'show-more-less-html__button').click()
# get description
jobdesc = driver.find_element(By.CLASS_NAME, "show-more-less-html__markup").text
## FOR COMPANY INFO
# scroll to top
driver.execute_script("window.scrollBy(0, -10000)")
# company page
comp = driver.find_element(By.CLASS_NAME, 'topcard__org-name-link.topcard__flavor--black-link')
cn = comp.text
comp.click()
# switch to new tab
tabs = driver.window_handles
driver.switch_to.window(tabs[-1])
# x button
xbutton = driver.find_elements(By.CLASS_NAME,'modal__dismiss')
for element in xbutton:
if element.aria_role == "button":
element.click()
# get description
compdesc = driver.find_element(By.XPATH, '//p[@data-test-id="about-us__description"]').text
driver.quit()
return jobInfo(jobdesc, compdesc, t + cn)