-
Notifications
You must be signed in to change notification settings - Fork 447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: pagesix parser #97
Conversation
Tests are passing but no image appeared on the preview. Not sure if that’s an issue.
// Is there anything in the content you selected that needs transformed | ||
// before it's consumable content? E.g., unusual lazy loaded images | ||
transforms: { | ||
'#featured-image-wrapper': 'figure', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue as the other PR where I'd like @adampash to verify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somehow I missed this. What did you want me to verify, @kev5873?
domain: 'pagesix.com', | ||
|
||
supportedDomains: [ | ||
'nypost.com', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also appears that nypost.com has a very similar layout, and appears to be compatible with this one, since they are in the same network of sites.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. 👍
7798ac4
to
82d9638
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few small optimizations.
domain: 'pagesix.com', | ||
|
||
supportedDomains: [ | ||
'nypost.com', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. 👍
'.modal-trigger', | ||
'.wp-caption-text', | ||
], | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's how I'd re-write the content extractor:
content: {
selectors: [
['#featured-image-wrapper', '.entry-content'],
'.entry-content',
],
// Is there anything in the content you selected that needs transformed
// before it's consumable content? E.g., unusual lazy loaded images
transforms: {
'#featured-image-wrapper': 'figure',
'.wp-caption-text': 'figcaption',
},
// Is there anything that is in the result that shouldn't be?
// The clean selectors will remove anything that matches from
// the result
clean: [
'.modal-trigger',
],
},
So, bit by bit:
selectors: [
['#featured-image-wrapper', '.entry-content'],
'.entry-content',
],
First, by focusing on .entry-content
instead of .article-header
, you don't have to clean near as much from the page (see the much smaller clean
section). You can still get the lead image by doing a multi-element selector for the content — this says get the #featured-image-wrapper
, then get the .entry-content
, and put them together.
transforms: {
'#featured-image-wrapper': 'figure',
'.wp-caption-text': 'figcaption',
},
This transform just changes div#featured-image-wrapper
to a figure
, which will then work correctly — and then we can also easily transform div.wp-caption-text
into a figcaption
.
…-parser into feat-pagesix-extractor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
Tests are passing but no image appeared on the preview. Not sure if
that’s an issue.