[Python] How to update a LinkedIn scraper that should work?

Discussão em 'Python' iniciado por Stack, Junho 1, 2025.

  1. Stack

    Stack Membro Participativo

    I am writing a Python program

    import requests
    import json
    import pandas as pd

    # Install necessary packages
    # pip3 install requests
    # pip3 install json
    # pip3 install pandas

    # Get LinkedIn access token
    ACCESS_TOKEN = 'YOUR_ACCESS_TOKEN'

    # Search for computer science students
    url = "https://api.linkedin.com/v2/search?q=computer%20science&facetField=location&facet=us:84&facet=us:101&count=100"
    headers = {
    "Authorization": f"Bearer {ACCESS_TOKEN}"
    }
    response = requests.get(url, headers=headers)

    # Parse JSON response
    data = json.loads(response.text)
    results = data.get("elements", [])

    # Extract profile details
    cs_students = []
    for result in results:
    name = result.get("title", {}).get("text","")
    contact = result.get("contactInfo", {}).get("emailAddress","")
    cs_students.append({"name": name, "contact": contact})

    # Create DataFrame
    df = pd.DataFrame(cs_students)

    # Export to Excel
    df.to_excel("cs_students.xlsx", index = False)


    How can I address this? I want to share free info with cool people on LinkedIn.

    Expected: An Excel sheet with names

    Current Output: An empty Excel Sheet

    What can I try next?

    Continue reading...

Compartilhe esta Página