开发者

Ruby Nokogiri getting plain text file

I am trying to get a .sql file from an http web server using this code.

Nokogiri::HTML(open($sql_file,:http_basic_authentication=>[@usr, @pwd]))

But i do get the sql file with some html tags.(e.g <html><body><p> at the beginning and at the end).

Do you know how can i get 开发者_如何学运维the file as plain text .sql file.


Nokogiri is for handling HTML and XML files. If you just want the raw text file, you don't need or want Nokogiri.

Use just the open-uri library (which you are already using) along with its read method to fetch the contents:

require 'open-uri'
sql = open($sql_file,:http_basic_authentication=>[@usr, @pwd]).read
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜