py-linkedin-jobs-scraper icon indicating copy to clipboard operation
py-linkedin-jobs-scraper copied to clipboard

export results to csv

Open zaiinabyy opened this issue 2 years ago • 3 comments

hello, is there a way to export the query results to csv file?

zaiinabyy avatar Mar 09 '22 16:03 zaiinabyy

Yes! Save it to a dataframe.

First I create a list:

def on_data(data: EventData): job_postings.append([data.job_id, data.location, data.title, data.company, data.date, data.link, data.description])

Then I put that in a DF

#Put the job postings into a dataframe df = pd.DataFrame(job_postings, columns=['Job_ID','Location','Title', 'Company', 'Date', 'Link', 'Description'])

jessebehrens avatar Mar 11 '22 16:03 jessebehrens

Where do you place that code? Also, it prompts, that job_postings is not defined.

leonpawelzik avatar Jul 07 '22 15:07 leonpawelzik

Find the function below and add the last line there. Be careful of the tab space. Need to tab once

def on_data(data: EventData):
    print('[ON_DATA]', data.title, data.company, data.company_link, data.date, data.link, data.insights,
          len(data.description))
    job_postings.append([data.job_id, data.location, data.title, data.company, data.date,
data.link, data.description])

and add these at the bottom

job_postings = []
scraper.run(queries)
df = pd.DataFrame(job_postings, columns=['Job_ID','Location','Title', 'Company','Date', 'Link', 'Description'])
df.to_csv("jobs.csv")

Prashanthvsdvn avatar Feb 08 '23 00:02 Prashanthvsdvn