Persistence pays off!
Thank you John for the elegant, straightforward and surprisingly short
solution to my request. If anyone else tries to run this in Factor 0.96,
"http-get" is in the *http.client* vocabulary and "json>" is in *json.reader
* (neither was suggested by the listener). Also, I correctly guessed that
the "foreground" that was needed was in the *ui.render* vocabulary (the
listener gave two choices).
This tool works great, giving me a nice list of posts. However, your
statement "URLs that can be right-clicked and opened in your browser" makes
me wonder if I'm missing something. At least in Windows, if I right-click
on a post, the listener pops up a little window with: "Inspector, a
delineating line, then Prettyprint, Push, Unparse and Watch". From any of
these I can see something like *URL"
http://re-factor.blogspot.com/..."*and I can easily extract something
I can paste in my browser address line,
but nothing that opens directly in my browser. I'm certainly not
complaining - I'm very happy with my new tool - just curious.
Thanks again,
-John
On Thu, Sep 5, 2013 at 1:44 PM, John Benediktsson <mrj...@gmail.com> wrote:
> Another idea is to use the Blogger API, and scrape the resulting JSON
> containing all my posts.
>
> You can make a URL on my blog like so:
>
> : re-factor-url ( str -- url )
> "http://re-factor.blogspot.com/" prepend ;
>
> Getting all the posts back as a huge JSON document (right now I have like
> 170 posts, so 200 max results should be "good enough" for awhile):
>
> : posts-url ( -- url )
> "feeds/posts/default?alt=json&max-results=200" re-factor-url ;
>
> All the posts can be found by navigating the json document to the "feed"
and
> "entry" keys, memoizing so subsequent calls in the listener are fast:
>
> MEMO: all-posts ( -- posts )
> posts-url http-get nip json> { "feed" "entry" } [ of ] each ;
>
> Then, you can print them out in the listener, and make them URLs that can
be
> right-clicked and opened in your browser:
>
> CONSTANT: post-style H{
> { foreground COLOR: blue }
> }
>
> : posts. ( -- )
> all-posts [
> [ "title" of "$t" of ] [ "link" of ] bi
> over '[ "title" of _ = ] find nip "href" of
> >url post-style [ write-object ] with-style nl
> ] each ;
>
> How's that?
>
>
>
>
>
>
> On Thu, Sep 5, 2013 at 9:04 AM, John Porubek <jporu...@gmail.com> wrote:
>>
>> I'm re-posting this message since I didn't get an answer the first
>> time and I'm nothing if not persistent!
>>
>> Let me recast the original question differently. Is there a fairly
>> easy way, using Factor, to scrape a blog website for a list of blog
>> titles? This seems like it would be a really useful tool for finding
>> information, assuming the author chose fairly meaningful titles.
>>
>> I'm no expert in web technology, but it occurs to me, as I think about
>> this problem, that it might be kind of difficult in the general case.
>> I have no idea how similar different blogs might be. For now, I'm most
>> interested in the special case of John Benediktsson's "Re:Factor"
>> blog.
>>
>> Thanks,
>>
>> -John
>>
>> ---------- Forwarded message ----------
>> From: John Porubek <jporu...@gmail.com>
>> Date: Mon, Aug 19, 2013 at 5:52 PM
>> Subject: Re: [Factor-talk] Wiki Tutorial
>> To: factor-talk@lists.sourceforge.net
>>
>>
>> John,
>>
>> Is there a way to get an index (one line per blog entry) of all your
>> posts? Google Reader used to do that for me. Feedly provides a nice
>> listing, but it only goes back about a year (I don't know about other
>> RSS readers - anybody care to suggest a better one?). The search
>> feature is appreciated, but is not always what I need, because often I
>> don't know what to call what I'm looking for.
>>
>> Your blog has been an invaluable source of information (and sometimes
>> inspiration!) for me. Thanks for your efforts.
>>
>> -John
>>
>> P.S. Chris Double's blog is also quite helpful and this link:
>> http://www.bluishcoder.co.nz/tags/factor/ , presents a nice index.
------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk