CA
Crawlee & Apify•3y ago
passive-yellow

Python Functions?

Am I able to use Python functions when creating an actor? Up until recently I haven't used functions because I didn't understand them fully but now I have a better grasp on them. My code works on its own and I only ask because I got a syntax error when trying to run it as an actor and want to know if it's because of my code or compatibility issues. Thanks in advance! Code giving the error
book.append({
'title: ' get_title(doc),
'price: ' get_price(doc),
'publisher: ' get_pub(doc),
'copyright: ' get_copy(doc),
'descripion: ' get_desc(doc),
'image: ' get_image(doc),
})
book.append({
'title: ' get_title(doc),
'price: ' get_price(doc),
'publisher: ' get_pub(doc),
'copyright: ' get_copy(doc),
'descripion: ' get_desc(doc),
'image: ' get_image(doc),
})
Log
2022-10-22T02:53:58.993Z ACTOR: Pulling Docker image from repository.
2022-10-22T02:53:59.215Z ACTOR: Creating Docker container.
2022-10-22T02:53:59.415Z ACTOR: Starting Docker container.
2022-10-22T02:54:01.251Z File "/usr/src/app/main.py", line 78
2022-10-22T02:54:01.252Z 'title: ' get_title(doc),
2022-10-22T02:54:01.253Z ^
2022-10-22T02:54:01.253Z SyntaxError: invalid syntax
2022-10-22T02:53:58.993Z ACTOR: Pulling Docker image from repository.
2022-10-22T02:53:59.215Z ACTOR: Creating Docker container.
2022-10-22T02:53:59.415Z ACTOR: Starting Docker container.
2022-10-22T02:54:01.251Z File "/usr/src/app/main.py", line 78
2022-10-22T02:54:01.252Z 'title: ' get_title(doc),
2022-10-22T02:54:01.253Z ^
2022-10-22T02:54:01.253Z SyntaxError: invalid syntax
3 Replies
MEE6
MEE6•3y ago
@SmilinDesperado just advanced to level 2! Thanks for your contributions! 🎉
!!!Joefree!!! 👑
its syntax error, the quotes misplace, it should be 'title': get_title(doc)
passive-yellow
passive-yellowOP•3y ago
thank you. i'm still learning

Did you find this page helpful?