forked from riyaa14/Updates_Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
amazon.py
51 lines (42 loc) · 1.57 KB
/
amazon.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
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
import pymongo
from pymongo import MongoClient
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
url = 'https://www.amazon.jobs/en/job_categories/software-development'
# driver = webdriver.Chrome()
client=pymongo.MongoClient("mongodb://localhost:27017/")
print(client)
db=client["DiscordBot"]
collection=db["Website"]
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.execute_script("window.scrollTo(0, 1000)")
time.sleep(5)
WebDriverWait(driver, 10).until(
EC.presence_of_all_elements_located((By.CLASS_NAME, "job")))
jobSection = driver.find_element(By.CLASS_NAME, 'job')
title = jobSection.find_element(By.TAG_NAME, 'h3').text
location = jobSection.find_element(By.TAG_NAME, 'p').text
desc = jobSection.find_element(By.CLASS_NAME, 'description').text
id="1"
post= {"id":id,"title":title,"location":location,"description":desc}
collection.insert_one(post)
# message that bot will send
print(title)
print(location)
print(desc)
print(url)
##### for database #######
# 1. title
# 2. location
# 3. desc