Skip to content

Handle URLs with anchors #8

@jhass

Description

@jhass

Anchor tags are a valid part of an URI but shouldn't be included in the request.

url = "http://www.cnet.com/news/pi-top-the-3d-printable-raspberry-pi-laptop-anyone-can-build/#ftag=CAD590a51e"

require 'uri'
require 'open-uri'
require 'nokogiri'

p Nokogiri::HTML(open URI.parse(url), &:read).css('title').text #=> "Pi-Top: The 3D-printable Raspberry Pi laptop anyone can build - CNET"

require 'opengraph_parser'
p OpenGraph.new(url).title #=> "Page Not Found (404) - CNET"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions