denkan / cheerio-json-mapper Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Love this library, its exactly what cheerio is missing. Hopefully they'll merge it in!
I'm using the JSON mapper to pull marketing data about our competition from Clutch.
The following errors though when Im trying to get the attribute of the current element. I assume I'm doing it wrong.
Error: Empty sub-selector
{"companies": [
{
"$": "ul.directory-list li.provider-row",
"clutchId": "$ | attr:data-clutch-pid",
"title": ".company_info a",
"tagline": ".tagline",
"rating": ".rating",
"reviewCount": ".reviews-link",
"minProjectSize": "div [data-content='<i>Min. project size</i>'] span",
"avgHourlyRate": "div [data-content='<i>Avg. hourly rate</i>'] span",
"employees": "div [data-content='<i>Employees</i>'] span",
"location": "div [data-content='<i>Location</i>'] span"
}
]}
The error occurs when I include the line
"clutchId": "$.attr",
This is the HTML Im parsing at this point
<ul class="directory-list"> <li data-position="1" id="provider-12345" data-type="Sponsor" class="provider provider-row sponsor" data-is-list="true" data-clutch-pid="12345" data-title="XXXX"
Is it possible to to do something like
const html= `
<table>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>John</td>
<td>30</td>
</tr>
<tr>
<td>Jane</td>
<td>28</td>
</tr>
</table>
`;
const schema = [
{
"th: "td"
}
]
which would map to:
[
{
"Name": "John",
"Age": "30"
},
{
"Name": "James",
"Age": "28"
},
]
I was expecting the pipe "parseAs:date" to return a Date object and not a string.
https://github.com/denkan/cheerio-json-mapper/blob/ec23188ce90353c3d046671e073de3537a622759/src/cheerio-json-
mapper.ts#L53
What is the idea behind that? Just to see if the string is a valid date?
Hi, I think this librarry is awsome so i create a website with next js to visually and make scraping easy, You just need the schema and lists of website you want to scrape, I hope this website help someone, Thank you .
website: https://perfrico.vercel.app/
github: https://github.com/iabdrahim/perfrico
Thanks for writing this app, since cheerio can't seem to release a new version since 6 months!
I wonder why you choose to return a Promise<unknown>
instead of a promise with the structure of the template (types)?
I guess its not easy to derive the type from the piped values, but how about adding a template argument to the function where we can specifiy the resulting objects shape?
Or have you looked at [zod](https://www.npmjs.com/package/zod)
which is completely typesafe and also supports the concept of pipes (althought differently named).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.