#!/usr/bin/env python
# coding: utf-8

# In[21]:


import requests

URL = 'https://www.monster.com/jobs/search/?q=Data-Analyst&where=india'
page = requests.get(URL)


# In[23]:


print (page.content)


# In[25]:


import requests
from bs4 import BeautifulSoup

URL = 'https://www.monster.com/jobs/search/?q=Software-Developer&where=Australia'
page = requests.get(URL)

soup = BeautifulSoup(page.content, 'html.parser')


# In[26]:


print(soup)


# In[27]:


results = soup.find(id='ResultsContainer')


# In[28]:


print(results)


# In[29]:


print(results.prettify())


# In[30]:


job_elems = results.find_all('section', class_='card-content')


# In[34]:


for job_elem in job_elems:
    print(job_elem, end='\n'*5)


# In[35]:


for job_elem in job_elems:
    # Each job_elem is a new BeautifulSoup object.
    # You can use the same methods on it as you did before.
    title_elem = job_elem.find('h2', class_='title')
    company_elem = job_elem.find('div', class_='company')
    location_elem = job_elem.find('div', class_='location')
    print(title_elem)
    print(company_elem)
    print(location_elem)
    print()


# In[36]:


for job_elem in job_elems:
    title_elem = job_elem.find('h2', class_='title')
    company_elem = job_elem.find('div', class_='company')
    location_elem = job_elem.find('div', class_='location')
    if None in (title_elem, company_elem, location_elem):
        continue
    print(title_elem.text.strip())
    print(company_elem.text.strip())
    print(location_elem.text.strip())
    print()


# In[37]:


python_jobs = results.find_all('h2',
                               string=lambda text: 'python' in text.lower())


# In[38]:


print(len(python_jobs))


# In[39]:


python_jobs = results.find_all('h2',
                               string=lambda text: "python" in text.lower())

for p_job in python_jobs:
    link = p_job.find('a')['href']
    print(p_job.text.strip())
    print(f"Apply here: {link}\n")

