-
Notifications
You must be signed in to change notification settings - Fork 1
/
josaa.py
33 lines (25 loc) · 869 Bytes
/
josaa.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
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import pymongo
from pymongo import MongoClient
client=pymongo.MongoClient("mongodb://localhost:27017/")
print(client)
db=client["DiscordBot"]
collection=db["Website"]
id="3"
url = 'https://josaa.nic.in/'
driver = webdriver.Chrome()
driver.maximize_window() # For maximizing window
driver.implicitly_wait(10) # gives an implicit wait for 20 seconds
driver.get(url)
updatesSection = driver.find_element(By.CLASS_NAME, 'gen-list')
title = updatesSection.find_element(By.TAG_NAME, 'a').text
link = updatesSection.find_element(By.TAG_NAME, 'a').get_attribute('href')
post= {"id":id,"title":title,"link":link}
collection.insert_one(post)
print(title)
print(link)
##### for database ####
# 1. title
# 2. link