Web scraper with Selenium


from requests import get
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

chrome_options = Options()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument("--disable-dev-shm-usage")

browser = webdriver.Chrome(options=chrome_options)

browser.get("<https://kr.indeed.com/jobs?q=python&limit=50>")

base_url= "<https://kr.indeed.com/jobs>"
search_term = "python"

response = get(f"{base_url}{search_term}")

if response.status_code == 200:
  soup = BeautifulSoup(response.text,"html.parser")
  job_list = soup.find("ul",class_="jobsearch-ResultsList")
  jobs = job_list.find_all('li',recursive = False)
  print(jobs)
else:
  print(response.status_code,"Can not request page")
  # 403이 뜨는 이유는 indeed.com이 봇인지 검사를 하기 때문이다.
  print(response.text)
  # 이 페이지는 봇으로부터 보호하는데 사용하는 서비스인 클라우드 플레어가 만든 페이지이다.
  
  # Selenium을 사용해서 해결할 수 있다.
  # selenium은 브라우저를 자동화 할 수 있는 프로그램이다.