Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6861981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:36:16+00:00 2026-05-27T02:36:16+00:00

My Ruby/Nokogiri script is: require ‘rubygems’ require ‘nokogiri’ require ‘open-uri’ f = File.new(enterret +

  • 0

My Ruby/Nokogiri script is:

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

f = File.new("enterret" + ".txt", 'w')

1.upto(100) do |page|
  urltext = "http://xxxxxxx.com/" + "page/"
  urltext << page.to_s + "/"
  doc = Nokogiri::HTML(open(urltext))
  doc.css(".photoPost").each do |post|
    quote = post.css("h1 + p").text
    author = post.css("h1 + p + p").text
    f.puts "#{quote}" + "#{author}"
    f.puts "--------------------------------------------------------"
  end
end

When running this script i get the following error:

http.rb:2030:in `read_status_line': wrong status line: "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"" (Net::HTTPBadResponse)

However my script writes to file correctly, it just that this error keeps coming up. What does the error mean?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:36:16+00:00Added an answer on May 27, 2026 at 2:36 am

    Without knowing what site you are accessing it is hard to say for sure, but I suspect that the problem isn’t in Nokogiri.

    The error is being reported by http.rb, which would most likely be complaining about the HTTPd headers being returned. http.rb is concerned with the handshake with the HTTPd server and would whine about missing/malformed headers, but it wouldn’t care about the payload.

    Nokogiri, on the other hand, would be concerned about the payload, i.e., the HTML. The DOCTYPE is supposed to be part of the HTML payload, so I suspect their server is sending a HTML DOCTYPE instead of a MIME doctype, which should be "text/html".

    In the Ruby 1.8.7 http.rb file you’ll see the following lines at 2030 in the code:

    def response_class(code)
      CODE_TO_OBJ[code] or
      CODE_CLASS_TO_OBJ[code[0,1]] or
      HTTPUnknownResponse
    end
    

    That seems a likely place to generate the sort of message you’re seeing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The Ruby code: require 'nokogiri' f = open(doc2.xml) # f.each { |line| puts line}
I am using nokogiri and ruby to script some deployment scripts and I need
I am trying to read an XSD file using Nokogiri Ruby parser and it
I am trying to run a ruby script as root. When I try to
I've been trying to write a ruby script using mechanize to batch upload a
I'm stuck with this problem. cat ~/.rvm/gems/ruby-1.8.7-p249/gems/nokogiri-1.4.1/ext/nokogiri/mkmf.log Gives this errors (clipped) conftest.c:3: error: 'xmlParseDoc'
I'm newbie to Nokogiri ruby gem. I'm wondering how to read and write back
This Ruby code using Nokogiri doc.xpath(//tbody).remove removes the children of the <tbody> (as well
I'm creating a small app for myself where I run a Ruby script and
I have recently written some complex ruby script that eventually fails with segfaults in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.