rare-sapphire•4y ago
Making API request with crawlee?
I need to make an api POST request to retrieve information in the body . I tried using the Basic crawler, since it uses Got-scrapping under the hood. I've had no success and I optedfor installing an axios package instead.
The code
11 Replies
And what is the exact problem you have?
rare-sapphireOP•4y ago
I just wanted to understand why it didn't work with BasicCrawler, is there a mistake in my code?
I cannot tell because I would have to analyze that you are passing everything correctly. Look at the
got library for correct paramsrising-crimson•4y ago
HTTP crawler | Crawlee
This example demonstrates how to use HttpCrawler to crawl a list of URLs from an external file, load each URL using a plain HTTP request, and save HTML.
rare-sapphireOP•4y ago
How can I use Http crawler for a post request with custom headers and body ?
@Joaquim just advanced to level 2! Thanks for your contributions! 🎉
rising-crimson•4y ago
Here's an example:
rising-crimson•4y ago
I'd recommend checking out the
RequestOptions interface to understand all the options available:
https://crawlee.dev/api/core/interface/RequestOptionsRequestOptions | API | Crawlee
Specifies required and optional fields for constructing a {@apilink Request}.
rare-sapphireOP•4y ago
Thanks really helpful, I guess I won't need install axios in future projects after I master this
You can also do any extra HTTP with
context.sendRequest from the handlerrare-sapphireOP•3y ago
Isn't it more convenient or equal to use addRequest ?