Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #### This program scrapes naukri.com's page and gives our result as a
- #### list of all the job_profiles which are currently present there.
- import requests
- from bs4 import BeautifulSoup
- from selenium import webdriver
- from selenium.webdriver.common.keys import Keys
- from selenium.webdriver.chrome.service import Service
- from selenium.webdriver.chrome.options import Options
- import time
- import sys
- #sys.stdout=open('test.txt','w')
- url = "https://wazirx.com/exchange/BTC-INR"
- chrome_options=Options()
- chrome_options.add_argument("--headless")
- chrome_options.add_argument("--no-sandbox")
- chrome_options.add_argument("window-size=1400,2100")
- driver = webdriver.Chrome(executable_path='./chromedriver',options=chrome_options)
- driver.get(url)
- time.sleep(15)
- html = driver.page_source
- soup = BeautifulSoup(html, "html.parser")
- all_divs = soup.find('div', {'class' : 'sc-iELTvK bZNgpE'})
- job_profiles = all_divs.find_all('a')
- print("-------------------------------------------------")
- print("|",end="")
- print("Market Name".center(15," "),end='')
- print("|",end='')
- print("Market Change".center(16," "),end='')
- print("|",end='')
- print("Market Price ".center(15," "),end='')
- print("|")
- print("-------------------------------------------------")
- for i in job_profiles:
- market_name=i.find('span',{'class':'market-name-text'})
- temp=i.find('span',{'color':'#00C853','class':'sc-bwzfXH cFmqCk'})
- if temp is not None:
- market_change="+"+temp.text.encode('utf-8').decode('ascii', 'ignore')
- #print(f"{market_name.text}(+{market_change})")
- else:
- temp=i.find('span',{'color':'#f44336','class':'sc-bwzfXH jsJuLQ'})
- market_change="-"+temp.text.encode('utf-8').decode('ascii', 'ignore').replace("-","")
- #print(f"{market_name.text}({market_change})")
- price=i.find('span',{'class':'price-text ticker-price'}).text.encode('utf-8').decode('ascii', 'ignore')
- #print(f"{market_name}(+{market_change})")
- print("|")
- print(market_name.text.strip('/inr').upper().center(15," "),end='|')
- print(market_change.center(16," "),end='|')
- print(price.center(15," "),"|")
- print("-------------------------------------------------")
- #print(f"{market_name.text.strip('/inr').upper()} Market Change: (+{market_change}) Price: {price}")
- #sys.stdout.close()
- driver.close() # closing the webdriver
Advertisement
Add Comment
Please, Sign In to add comment