3

Basic question, but my first five minutes of looking through documentation told me nothing useful.

In rebol 2:

>> read http://www.google.com
== {<!doctype html><html itemscope="itemscope" itemtype="http://schema.org/WebPage"><head><meta content="Search the world's informa...

In rebol 3:

>> read http://www.google.com
== #{
3C21646F63747970652068746D6C3E3C68746D6C206974656D73636F70653D22
6974656D73636F706522206974656D747970653D22687474703A2F2F73636865
6D612E6F72672F57656250616765223E3C686561643E3C6D65746120636F6E74
656E743D225365617263682074686520776F726C64277320696E666F726D6174
696F6E2C20696E636C7564696E672077656270616765732C20696D616765732C
20766964656F7320616E64206D6F72652E20476F6F676C6520686173206D616E
79207370656369616C20666561747572657320746F2068656C7020796F752066
696E642065786163746C79207768617420796F7527...

I realize this is base-16 binary, but how do I get it into a form that is easy to parse? Do I need to convert the parse rules into binary first?

4

2 回答 2

3

The base-16 output you see is the pretty-printed representation for what is internally just a plain binary!, a sequence of 8-bit bytes:

>> type? read http://www.rebol.com/       
== binary!

parse works just fine with a binary!, so you could just use the result with PARSE straight away.

Alternatively, you can UTF-8 decode the result into a string! via to-string:

>> type? to-string read http://www.rebol.com/
== string!
于 2013-07-11T21:57:44.903 回答
3

Or, to more closely mirror your question, here's the string output

>> to-string read http://www.rebol.com/
== {<!doctype html>
<html><head>    
<meta name="generator" content="REBOL WIP Wiki"/>
<meta name="date" content="24-Jun-2013/20:08:20-7:00"/>
..
于 2013-07-12T09:02:33.200 回答