Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

location filter in search_jobs doesn't work #475

Open
tonorgguillamon opened this issue Jan 12, 2025 · 3 comments
Open

location filter in search_jobs doesn't work #475

tonorgguillamon opened this issue Jan 12, 2025 · 3 comments

Comments

@tonorgguillamon
Copy link

tonorgguillamon commented Jan 12, 2025

Hi,
when using search_jobs, it seems that the location filter is ignored.

Notice in the example, location: Berlin

/voyagerJobsDashJobCards?decorationId=com.linkedin.voyager.dash.deco.jobs.search.JobSearchCardsCollection-174&count=10&q=jobSearch&query=(origin:JOB_SEARCH_PAGE_QUERY_EXPANSION,keywords:engineer,locationFallback:Berlin,selectedFilters:(timePostedRange:List(r86400)),spellCorrectionEnabled:true)&start=0

The search returns only results from my current country, not even an accurate location such as the city, (i guess taken from the browser cookies).

image

Anybody knows how this filter actually works?

@space192
Copy link

I'm having the same issue did you find any solution ?

@salvatorenitopi
Copy link

salvatorenitopi commented Jan 15, 2025

I found a workaround, locationUnion can be used instead of locationFallback,

I added to the function the location_id parameter and commented out location_name

then I added a new query parameter: query["locationUnion"] = f"(geoId:{location_id})" and commented out the locationFallback one.

You can find a list of IDs here: https://support.captaindata.co/hc/en-us/articles/18071222083485-List-of-GeocodeURN-to-use-in-your-Geography-Parameter

Below in detail what I changed in the function:

def search_jobs(
    self,
    keywords: Optional[str] = None,
    companies: Optional[List[str]] = None,
    experience: Optional[
        List[
            Union[
                Literal["1"],
                Literal["2"],
                Literal["3"],
                Literal["4"],
                Literal["5"],
                Literal["6"],
            ]
        ]
    ] = None,
    job_type: Optional[
        List[
            Union[
                Literal["F"],
                Literal["C"],
                Literal["P"],
                Literal["T"],
                Literal["I"],
                Literal["V"],
                Literal["O"],
            ]
        ]
    ] = None,
    job_title: Optional[List[str]] = None,
    industries: Optional[List[str]] = None,
    # location_name: Optional[str] = None,
    remote: Optional[List[Union[Literal["1"], Literal["2"], Literal["3"]]]] = None,
    listed_at=24 * 60 * 60,
    distance: Optional[int] = None,
    limit=-1,
    offset=0,
    location_id="102299470",
    **kwargs,
) -> List[Dict]:

    count = Linkedin._MAX_SEARCH_COUNT
    if limit is None:
        limit = -1

    query: Dict[str, Union[str, Dict[str, str]]] = {
        "origin": "JOB_SEARCH_PAGE_QUERY_EXPANSION"
    }
    if keywords:
        query["keywords"] = "KEYWORD_PLACEHOLDER"
    # if location_name:
    #    query["locationFallback"] = "LOCATION_PLACEHOLDER"

    # In selectedFilters()
    query["selectedFilters"] = {}
    if companies:
        query["selectedFilters"]["company"] = f"List({','.join(companies)})"
    if experience:
        query["selectedFilters"]["experience"] = f"List({','.join(experience)})"
    if job_type:
        query["selectedFilters"]["jobType"] = f"List({','.join(job_type)})"
    if job_title:
        query["selectedFilters"]["title"] = f"List({','.join(job_title)})"
    if industries:
        query["selectedFilters"]["industry"] = f"List({','.join(industries)})"
    if distance:
        query["selectedFilters"]["distance"] = f"List({distance})"
    if remote:
        query["selectedFilters"]["workplaceType"] = f"List({','.join(remote)})"

    query["selectedFilters"]["timePostedRange"] = f"List(r{listed_at})"
    query["spellCorrectionEnabled"] = "true"
    query["locationUnion"] = f"(geoId:{location_id})"

Then you call the function as follows:

response = linkedin_client.search_jobs(
    keywords="myjob".replace(" ", "%20"),
    location_id="102299470",
    remote="2",
    listed_at=24*60*60,
    limit=-1,
    offset=0
)

It ended up generating this query:

(origin:JOB_SEARCH_PAGE_QUERY_EXPANSION,keywords:myjob,selectedFilters:(workplaceType:List(2),timePostedRange:List(r86400)),spellCorrectionEnabled:true,locationUnion:(geoId:102299470))

I hope this can help you

@tonorgguillamon
Copy link
Author

yep, that´s the workaround I found. It is just very painful to go id by id mapping the location. By countries might be feasible, but if you wanna go more detailed, like cities,..give it up.

i tried to figure out which function Linkedin is using to relate location with geoId, but no success

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants