Multiple usernames for single actor run not working
I am trying to leverage the apify-client for Python to kick off an execution of the Instagram Reel Scraper (apify/instagram-reel-scraper) via API. I have been successful in running this in a "one-to-one" scenario where I run it for a single Instagram handle and it returns ten results as expected. However, I want to be able to pass ~1,600 instagram IDs with a single API call. You can do this through the web console quite easily and it runs without a problem. I can even edit the JSON to execute all ~1,600. However, whenever I try to pass my payload through the API it skips all of the instagram handles. I am curious if it's possible I am not building my payload correctly, or maybe something else. I have been unsuccessful in finding documentation that speaks specifically to the use case I have. I would be happy to read up on documentation if it exists. Thanks in advance!
3 Replies
metropolitan-bronzeOP•15mo ago
Here is an example of the log output I get when the actor runs.
ratty-blush•15mo ago
I see there is
WARN Skipped incorrect URL: {"urlStringOrObject":"[\"instagramhandle1 \", \"instagramhandle2\", \"instagramhandle3\", \"instagramhandle4\", \"instagramhandle5\"
So maybe try to check the input structure (your payload) and ensure that everything is correct there. Especially, if Your input works correct on the platform. It must be something with the payload.
Try to double-check it. Or provide some reproduction, so we can check it (snippet, where You make a call of the scraper)metropolitan-bronzeOP•15mo ago
Certainly. Here is the code that is supposed to be building the payload:
The function
def scrape_instagram(user):
is in a separate python file. That code is:
Ok, I (finally) resolved the problem. You were correct @Oleg V. . It was a malformed payload. The solution for me was to abandon the conversion to json using the json_payload = json.dumps(instagram_handles)
code. Instead I am just passing the result of instagram_handles = [user['instagramHandle'] for user in users]
. The other key element is I had to drop the square brackets in the run_input
command. Instead of "username": [user]
I changed it to "username": user