Skip to content
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

Merged
merged 13 commits into from
Feb 7, 2017
Merged

feat: pagesix parser #97

merged 13 commits into from
Feb 7, 2017

Conversation

janetleekim
Copy link
Contributor

Tests are passing but no image appeared on the preview. Not sure if
that’s an issue.

janetleekim and others added 2 commits December 20, 2016 12:26
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',
Copy link
Contributor

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.

Copy link
Contributor

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',
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. 👍

Copy link
Contributor

@adampash adampash left a 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',
Copy link
Contributor

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',
],
},
Copy link
Contributor

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.

Copy link
Contributor

@dviramontes dviramontes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@kev5873 kev5873 merged commit beb0b89 into master Feb 7, 2017
@kev5873 kev5873 deleted the feat-pagesix-extractor branch February 7, 2017 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants