Skip to content

feat(crawlers): Add extract_form_requests helper for HTTP crawlers with HTML parsers - #2257

Open
Mantisus wants to merge 8 commits into
apify:masterfrom
Mantisus:form-request
Open

Mantisus wants to merge 8 commits into
apify:masterfrom
Mantisus:form-request

Conversation

@Mantisus

@Mantisus Mantisus commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Description

  • Adds extract_form_requests to ParselCrawlingContext and BeautifulSoupCrawlingContext. It reads a form from the page, fills in the given values and returns requests that submit it the way a browser does, keeping hidden fields such as CSRF tokens. By default, one form is submitted: the one sharing the most field names with fields. The selector, click and all_forms arguments pick the forms and the submit button.

Testing

  • Added new unit tests

@Mantisus Mantisus changed the title feat(crawlers): add form_requests helper for HTTP crawlers with HTML parsers feat(http-crawlers): add form_requests helper for HTTP crawlers with HTML parsers Sep 25, 2026
@Mantisus
Mantisus marked this pull request as draft September 25, 2026 19:06
@Mantisus Mantisus changed the title feat(http-crawlers): add form_requests helper for HTTP crawlers with HTML parsers feat(http-crawlers): Add extract_form_requests helper for HTTP crawlers with HTML parsers Sep 28, 2026
@Mantisus Mantisus self-assigned this Sep 29, 2026
@Mantisus
Mantisus force-pushed the form-request branch 4 times, most recently from cfd9dde to 47e4629 Compare October 1, 2026 10:43
@Mantisus Mantisus changed the title feat(http-crawlers): Add extract_form_requests helper for HTTP crawlers with HTML parsers feat(crawlers): Add extract_form_requests helper for HTTP crawlers with HTML parsers Oct 1, 2026
@Mantisus
Mantisus marked this pull request as ready for review October 1, 2026 10:52
@Mantisus
Mantisus requested review from Pijukatel and vdusek October 1, 2026 10:53
@Pijukatel

Copy link
Copy Markdown
Collaborator

Currently, this is supported as user-specific code. What motivated adding it as a dedicated helper in the library?

@Mantisus

Mantisus commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator Author

I believe it'll be quite useful for users, since it removes a fair amount of boilerplate. A good example is a form on an ASP.NET site, which may have a single user field next to several hidden fields that need specific handling, like __VIEWSTATE, __EVENTVALIDATION and the clicked submit button. It should also make migrating from Scrapy easier, since Scrapy has similar functionality.

@vdusek vdusek 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.

LGTM

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants