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

Respect base tags #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

ericmason
Copy link

Currently <base href="..."> tags are not taken into account and will send the spider to the wrong URL on pages with a base tag. With this patch, the spider correctly calculates absolute URLs when a base tag is present.

@ericmason ericmason changed the title Respect <base href="..."> tags Respect base tags Feb 17, 2017
Copy link
Owner

@postmodern postmodern left a comment

Choose a reason for hiding this comment

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

Spotted a few minor things.


def base_uri
if (html? && doc)
base_tag = doc.search('//base[@href]').first
Copy link
Owner

Choose a reason for hiding this comment

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

To avoid pulling in all matching nodes, should use doc.at(...) instead of .search.

def base_uri
if (html? && doc)
base_tag = doc.search('//base[@href]').first
base_tag ? URI(base_tag.get_attribute('href')) : url
Copy link
Owner

Choose a reason for hiding this comment

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

I try to avoid using trinary flip-flop expressions. I would use a standard if (foo = ...) then foo.bar / else baz here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants