Issue
HTML tags appears is the CSV file
Solution
Here is updated version of your code.
import requests
from bs4 import BeautifulSoup
import csv
import os
csv_file = open(os.getcwd()+"\data.csv", "a", newline="")
csv_writer = csv.writer(csv_file)
csv_writer.writerow(["job_title", "company_name", "location", "job_skills", "link"])
for i in range(0, 10):
result=requests.get(f'https://wuzzuf.net/search/jobs/?a=hbp&q=python&start={i}')
soup=BeautifulSoup(result.content,'lxml')
base_url = "https://wuzzuf.net"
# find all job posts card
job_posts = soup.find_all("div", {"class": "css-1gatmva e1v1l3u10"})
for job_post in job_posts:
job_title = job_post.find("h2", {"class": "css-m604qf"}).find("a").text
company_name = job_post.find("div", {"class" : "css-d7j1kk"}).find("a").text[:-2]
location = job_post.find("div", {"class" : "css-d7j1kk"}).find("span").text
job_skills = job_post.find("div", {"class" : "css-1lh32fc"}).find_next_sibling("div").text
link = job_post.find("h2", {"class": "css-m604qf"}).find("a")["href"]
link_full = base_url + link
csv_writer.writerow([job_title,company_name,location,job_skills,link_full])
csv_file.close()
Answered By - skyriver
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.