-
Notifications
You must be signed in to change notification settings - Fork 1
/
microsoft.py
61 lines (46 loc) · 1.91 KB
/
microsoft.py
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
61
# /html/body/div[2]/div[2]/div/div[2]/div[1]/section[1]/div/div/div[3]/div[3]/div[1]/span/button
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
import time
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
# from webdriver_manager.chrome import ChromeDriverManager
import pymongo
from pymongo import MongoClient
client=pymongo.MongoClient("mongodb://localhost:27017/")
print(client)
db=client["DiscordBot"]
collection=db["Website"]
id="5"
url = 'https://careers.microsoft.com/students/us/en/search-results'
# driver = webdriver.Chrome()
options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(options=options)
driver.maximize_window() # For maximizing window
driver.implicitly_wait(10) # gives an implicit wait for 20 seconds
driver.get(url)
driver.find_element(
By.XPATH, '/html/body/div[2]/div[2]/div/div[2]/div[1]/section[1]/div/div/div[3]/div[3]/div[1]/span/button').click()
driver.find_element(
By.XPATH, '/html/body/div[2]/div[2]/div/div[2]/div[1]/section[1]/div/div/div[3]/div[3]/div[2]/div/div[3]/ul/li[8]/label/span[1]').click()
time.sleep(5)
WebDriverWait(driver, 10).until(
EC.presence_of_all_elements_located((By.CLASS_NAME, "information")))
driver.execute_script("window.scrollTo(0, 200)")
update = driver.find_element(By.CLASS_NAME, 'information')
heading = update.find_element(By.TAG_NAME, 'a')
# additionalInfo = update.find_elements(By.TAG_NAME, 'span')
post= {"id":id,"heading":heading.text}
collection.insert_one(post)
print(heading.text)
desc = ""
for info in additionalInfo:
desc += info.text
desc += '\n'
print(desc)
####### for database ########
# 1. heading
# 2. desc