feat: Add example of how to integrate Camoufox into PlaywrightCrawler by Pijukatel · Pull Request #789 · apify/crawlee-python · GitHub
Skip to content

feat: Add example of how to integrate Camoufox into PlaywrightCrawler - #789

Merged
Pijukatel merged 10 commits into
masterfrom
camoufox-example-code
Dec 12, 2024
Merged

Pijukatel merged 10 commits into
masterfrom
camoufox-example-code

Conversation

@Pijukatel

@Pijukatel Pijukatel commented Dec 6, 2024 •

Copy link
Copy Markdown
Collaborator

Description

Show how to integrate Camoufox into PlaywrightCrawler.
Added one docs page and one example code.
Added playwright-camoufox template to cli call crawlee create.
Fixed wrong template indentation when Apify integration was selected in cli.

Issues

@Pijukatel Pijukatel added documentation Improvements or additions to documentation. t-tooling Issues with this label are in the ownership of the tooling team. labels Dec 6, 2024
@github-actions github-actions Bot added this to the 104th sprint - Tooling team milestone Dec 6, 2024
@Pijukatel Pijukatel changed the title Add example of how to integrate Camoufox into PlaywrightCrawler. docs: Add example of how to integrate Camoufox into PlaywrightCrawler. Dec 6, 2024
@vdusek vdusek changed the title docs: Add example of how to integrate Camoufox into PlaywrightCrawler. docs: Add example of how to integrate Camoufox into PlaywrightCrawler Dec 6, 2024
@Pijukatel

Copy link
Copy Markdown
Collaborator Author

@Pijukatel
Pijukatel marked this pull request as ready for review December 10, 2024 09:38

@janbuchar janbuchar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job! I'm not sure about the docs prefix though - we also fix a bug in templates and add a new template to boot, so how about 'featorfix`?

"project_name": "crawlee-python-project",
"__package_name": "{{ cookiecutter.project_name|lower|replace('-', '_') }}",
"crawler_type": ["beautifulsoup", "parsel", "playwright"],
"crawler_type": ["beautifulsoup", "parsel", "playwright", "camoufox"],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to call this playwright-camoufox for example.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

# % endif
# % endblock
# % endfilter
{% if self.pre_main is defined %}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting trick! Could you use line expressions (# % if ...) here like in the rest of the file?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

# % endblock

# % block pre_main
class ExampleCamoufoxPlugin(PlaywrightBrowserPlugin):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave out the "Example" prefix 🙂

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

import asyncio

# This external package needs to be installed. It is not included in crawlee.
from camoufox import AsyncNewBrowser # type: ignore[import-not-found]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we ignore that check on the project level so that the example is cleaner?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +42 to +78

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a lot of stuff going on that could distract the reader from the actual gist of the example - could we pare it down a bit?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reduced most of the example and kept only minimal example that still demonstrates the use of the crawler.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you mention the new template here as well?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Pijukatel Pijukatel changed the title docs: Add example of how to integrate Camoufox into PlaywrightCrawler feat: Add example of how to integrate Camoufox into PlaywrightCrawler Dec 12, 2024
@Pijukatel Pijukatel added the enhancement New feature or request. label Dec 12, 2024
@Pijukatel
Pijukatel requested a review from janbuchar December 12, 2024 08:15
@Pijukatel
Pijukatel merged commit 246cfc4 into master Dec 12, 2024
@Pijukatel
Pijukatel deleted the camoufox-example-code branch December 12, 2024 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation. enhancement New feature or request. t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrate Camoufox into PlaywrightCrawler

2 participants