save HTML file using crawlee
# crawlee-js
n
Has anybody tried downloading the HTML file of the URL using Crawlee? Was wondering if Crawlee has a capacity of downloading the HTML file of the URL since I've just been using Crawlee and really loving the experience.
h
message has been deleted
e
You can download HTML content of a webpages using Crawlee
m
n
Thanks for this awesome answer! Was wondering if Crawlee has examples on how to save it to a file?
m
You can use the KeyValueStore: https://crawlee.dev/api/core/class/KeyValueStore. E.g., with Cheerio:
Copy code
await store.setValue('my-html', $.html('html'), { contentType: 'text/html' });
c
everything you save to a crawlee store is saved to disk, and can be accessed through crawlee or otherwise. Something my company is using is saving page.content() to a cloud storage bucket during the request handler which has worked quite well for us since it offloads the data nice and quickly.
s
1. I want to retrieve html for some specific table, say I want to retrieve html for "item-list" div in the code below (not the data inside each element). How to do this?
Copy code
<body>
    ...
    ...
    <div class="item-list">
        <div class="item">
            <div class="product-label"></div>
            <div class="product-image"></div>
            <div class="product-cost"></div>
        </div>
        <div class="item">
            <div class="product-label"></div>
            <div class="product-image"></div>
            <div class="product-cost"></div>
        </div>
        ...
        ...
    </div> <!-- end item-list -->
    ...
    ...
    <div class="testimonials">
        ...
        ...
        ...
    <div>
</body>
2. I do not want resultant html to be saved in a file/disk, I want to return my desired result to my api for further processing. How to do this?