From 71467ed9701493abad915e2cd341b3ed942b1f09 Mon Sep 17 00:00:00 2001 From: yoshith28 <131470348+yoshith28@users.noreply.github.com> Date: Fri, 16 Aug 2024 14:22:27 +0530 Subject: [PATCH 1/5] my first commit Testing my first commit --- test | 1 + 1 file changed, 1 insertion(+) create mode 100644 test diff --git a/test b/test new file mode 100644 index 000000000..0b73f8634 --- /dev/null +++ b/test @@ -0,0 +1 @@ +I am testing commit From 7d62c49f095e9830c0456c73bdf7516f89233c45 Mon Sep 17 00:00:00 2001 From: yoshith28 Date: Fri, 16 Aug 2024 15:01:46 +0530 Subject: [PATCH 2/5] My 2nd commit commiting from github desktop --- 21H51A0543/Yoshith.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 21H51A0543/Yoshith.txt diff --git a/21H51A0543/Yoshith.txt b/21H51A0543/Yoshith.txt new file mode 100644 index 000000000..558827d38 --- /dev/null +++ b/21H51A0543/Yoshith.txt @@ -0,0 +1 @@ +Hey I am Yoshith \ No newline at end of file From c425f6a66fa633cd66ba7df1bef667c0a926f8ad Mon Sep 17 00:00:00 2001 From: yoshith28 Date: Fri, 16 Aug 2024 15:04:36 +0530 Subject: [PATCH 3/5] 3rd commit Third commit --- 21H51A0543/Yoshith.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/21H51A0543/Yoshith.txt b/21H51A0543/Yoshith.txt index 558827d38..b04a04a47 100644 --- a/21H51A0543/Yoshith.txt +++ b/21H51A0543/Yoshith.txt @@ -1 +1,3 @@ -Hey I am Yoshith \ No newline at end of file +Hey I am Yoshith + +Holaaaa \ No newline at end of file From 637358a63398b2a90a6f471474ea92d360166729 Mon Sep 17 00:00:00 2001 From: yoshith28 Date: Fri, 16 Aug 2024 15:27:35 +0530 Subject: [PATCH 4/5] new branch commit commiting to a new branch --- A0543/test.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 A0543/test.txt diff --git a/A0543/test.txt b/A0543/test.txt new file mode 100644 index 000000000..5ab2f8a43 --- /dev/null +++ b/A0543/test.txt @@ -0,0 +1 @@ +Hello \ No newline at end of file From 1cbf809a28029c979b54fc450458cdb8f70776e9 Mon Sep 17 00:00:00 2001 From: yoshith28 <131470348+yoshith28@users.noreply.github.com> Date: Sun, 1 Sep 2024 22:50:37 +0530 Subject: [PATCH 5/5] Add files via upload --- api.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 api.py diff --git a/api.py b/api.py new file mode 100644 index 000000000..42110d4ad --- /dev/null +++ b/api.py @@ -0,0 +1,48 @@ +from flask import Flask, request, jsonify +import requests +from bs4 import BeautifulSoup +import urllib.parse + +app = Flask(__name__) + +@app.route('/scrape-linkedin', methods=['GET']) +def scrape_linkedin(): + # Retrieve 'job_role' and 'location' from query parameters + job_role = request.args.get('job_role', default='Frontend Developer', type=str) + location = request.args.get('location', default='India', type=str) + + # Encode the parameters to ensure they are URL-safe + job_role_encoded = urllib.parse.quote(job_role) + location_encoded = urllib.parse.quote(location) + + # Construct the LinkedIn URL with the dynamic job role and location + url = f'https://www.linkedin.com/jobs/search?keywords={job_role_encoded}&location={location_encoded}&pageNum=0' + + response = requests.get(url) + + if response.status_code == 200: + soup = BeautifulSoup(response.text, 'html.parser') + job_listings = soup.find_all('div', {'class': 'job-search-card'}) + + jobs = [] + + for job in job_listings: + title = job.find('h3', {'class': 'base-search-card__title'}).text.strip() + company = job.find('a', {'class': 'hidden-nested-link'}).text.strip() + location = job.find('span', {'class': 'job-search-card__location'}).text.strip() + anchor_tag = job.find('a', class_='base-card__full-link') + href_link = anchor_tag['href'] + + jobs.append({ + 'title': title, + 'company': company, + 'location': location, + 'link': href_link + }) + + return jsonify(jobs) + else: + return jsonify({'error': 'Failed to fetch job listings'}), 500 + +if __name__ == '__main__': + app.run(debug=True)