Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re^4: Web::Magic 0.005

by tobyink (Canon)
on Jan 13, 2012 at 13:43 UTC ( #947737=note: print w/replies, xml ) Need Help??

in reply to Re^3: Web::Magic 0.005
in thread Web::Magic 0.005

[App::scrape] does support RDF.

No, it does not. Accepting XML does not count as supporting RDF. In general, RDF cannot be effectively processed with XML tools.

Web::Magic won't help me "fake" a proper ua_string like WWW::Mechanize , and it has all those exceptions, but no cookie jar?

Web::Magic lets you specify any user agent string you like. The POD for the "set_request_header" method shows two examples of how to do precisely that:

$magic->set_request_header('User-Agent', 'MyBot/0.1'); $magic->User_Agent('MyBot/0.1'); # same as above

And if you have a cookie jar you'd like to use:


HTML::Query, Web::Query, Web::Scraper, Web::Magic ... a lot of the same kind of work, which horse to choose?

Sell me a horse?

Selecting stuff via CSS selectors is only a very small part of what Web::Magic does. (I almost regret using that feature in my first example.) Web::Magic aims to be the swiss army knife of HTTP-addressable resources. Whether it's a classic web page, a RESTful API, an Atom feed, or a WebDAV fileshare, Web::Magic can probably make dealing with it easier.

Let's suppose you have a RESTful API which supports up XML and JSON, depending on the request's HTTP Accept header. Web::Magic notices how you're trying to access the data, and does what you mean...

Web::Magic->new('') ->POST($xmldom) ->{entry}{id};

It's smart enough to figure out the HTTP headers you want:

POST /new-document HTTP/1.1
Content-Type: application/xml
Accept: application/json, text/x-yaml


But if you'd called it like this:

my @entries = Web::Magic->new('') ->POST({ title => "Hello", foo => 1 }) ->entries; print $entries[0]->id;

Then the request would be more like:

POST /new-document HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Accept: application/atom+xml, application/rss+xml


Replies are listed 'Best First'.
Re^5: Web::Magic 0.005
by Anonymous Monk on Jan 14, 2012 at 06:46 UTC

    Web::Magic lets you specify any user agent string you like.

    Um, yes, that is the problem, it doesn't help me concoct the correct string like Mechanize , its bare bones/vanilla LWP::UserAgent. With mechanize I use  $ua->agent_alias('Mac Mozilla'); or "Windows Mozilla", I don't have to go digging for the full string.


    Hat for your horse sir WWW::UserAgent::Random?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://947737]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2020-09-28 20:37 GMT
Find Nodes?
    Voting Booth?
    If at first I donít succeed, I Ö

    Results (144 votes). Check out past polls.