Hi Apify Community,
Hi Apify Community,
I successfully ran the LinkedIn scraper in the Apify environment and got the correct JSON response. However, I’m facing issues replicating the same in my local VSCode environment.
I’ve followed the steps to pass the LinkedIn cookies (exported using the "EditThisCookie" extension) into my input configuration, but I'm still getting an error: "Input is not valid: Field input.cookie is required."
Has anyone else encountered this issue or successfully run the LinkedIn scraper locally? I’m not sure if I’m missing something regarding the token or how to handle the cookies properly in a local setup. Any guidance on resolving this issue would be greatly appreciated!
Thanks in advance!
4 Replies
other-emerald•7mo ago
@Shamito post here
frail-apricot•7mo ago
Thanks!! 🫡
frail-apricot•7mo ago
I have already used the “Copy Cookies” extension, and it works perfectly when I paste the exported cookies into the Apify front-end. However, when I try to run the scraper locally in VSCode, I am not sure which of the cookies should be used and how exactly they should be passed in the code.
Could you help me with the correct structure for the code to run the scraper locally? Below is the code I am trying, but without any confidential credentials:
from apify_client import ApifyClient
Replace '<YOUR_API_TOKEN>' with your Apify API token
client = ApifyClient("<YOUR_API_TOKEN>")
Prepare the input for the Actor, with your LinkedIn URLs
run_input = {
"urls": [
"https://www.linkedin.com/in/ginoolivares/recent-activity/all/",
# Add more URLs for posts or profiles as needed
],
"minDelay": 2,
"maxDelay": 5,
"proxy": {
"useApifyProxy": True,
"apifyProxyCountry": "BR", # Or adjust the country as needed
},
# Here I tried to pass the cookies exported from the extension
"cookies": [
{
"name": "bcookie",
"value": "<your_bcookie_value>",
"domain": ".linkedin.com",
"path": "/",
"secure": True,
"httpOnly": False,
"sameSite": "None"
},
# Other copied cookies were also passed here
],
}
Run the Actor and wait for it to finish
run = client.actor("curious_coder/linkedin-post-search-scraper").call(run_input=run_input)
Display the link to access the data in Apify console
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
Iterate over the items in the dataset and print the results
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
print(item)
Even with this setup, Im still getting an error saying the cookie input is invalid. Could you give me an idea of how to correctly pass these cookies in VSCode?
@Shamito just advanced to level 1! Thanks for your contributions! 🎉