Hi All,
I am new to Python and trying the below code but not getting the desired output.
Library used: BeautifulSoup, Requests
Aim: To login into LinkedIn.
Fetch all the jobs
and write in output file.
Login in successful.
Now, i expect jobs page HTML to be fetched by python, just like all the jobs shown when i login from browser.
Instead job portal's login page is getting written in the output file.
I expected it to be logged in as I have maintained the session.
I am new to Python and trying the below code but not getting the desired output.
Library used: BeautifulSoup, Requests
Aim: To login into LinkedIn.
Fetch all the jobs
and write in output file.
Login in successful.
Now, i expect jobs page HTML to be fetched by python, just like all the jobs shown when i login from browser.
Instead job portal's login page is getting written in the output file.
I expected it to be logged in as I have maintained the session.
from bs4 import BeautifulSoup
import requests
session = requests.Session()
login_url = 'https://www.linkedin.com/uas/login-submit'
login_information = {
'session_key':'[email protected]',
'session_password':'12xxxxxx',
}
response = session.post(login_url,data=login_information)
if response.status_code != 200:
raise Exception("Invalid response %s." % response)
job_page = session.get('https://www.linkedin.com/jobs/')
soup = BeautifulSoup(job_page.content,'html.parser')
html = soup.prettify()
with open("job.html", "w",encoding='utf-8') as file:
file.write(str(html))
