{
    "content": [
        {
            "type": "text",
            "text": "# WWW::Mechanize::Cookbook (perldoc)\n\n## NAME\n\nWWW::Mechanize::Cookbook - Recipes for using WWW::Mechanize\n\n## Sections\n\n- **NAME**\n- **VERSION**\n- **INTRODUCTION**\n- **BASICS** (4 subsections)\n- **LINKS** (2 subsections)\n- **ADVANCED** (1 subsections)\n- **SEE ALSO**\n- **AUTHOR**\n- **COPYRIGHT AND LICENSE**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "WWW::Mechanize::Cookbook",
        "section": "",
        "mode": "perldoc",
        "summary": "WWW::Mechanize::Cookbook - Recipes for using WWW::Mechanize",
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "VERSION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "INTRODUCTION",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "BASICS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "Launch the WWW::Mechanize browser",
                        "lines": 7
                    },
                    {
                        "name": "Fetch a page",
                        "lines": 6
                    },
                    {
                        "name": "Fetch a page into a file",
                        "lines": 7
                    },
                    {
                        "name": "Fetch a password-protected page",
                        "lines": 6
                    }
                ]
            },
            {
                "name": "LINKS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "Find all image links",
                        "lines": 5
                    },
                    {
                        "name": "Find all download links",
                        "lines": 5
                    }
                ]
            },
            {
                "name": "ADVANCED",
                "lines": 1,
                "subsections": [
                    {
                        "name": "See what will be sent without actually sending anything",
                        "lines": 3
                    }
                ]
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "COPYRIGHT AND LICENSE",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "WWW::Mechanize::Cookbook - Recipes for using WWW::Mechanize\n",
                "subsections": []
            },
            "VERSION": {
                "content": "version 2.06\n",
                "subsections": []
            },
            "INTRODUCTION": {
                "content": "First, please note that many of these are possible just using LWP::UserAgent. Since\n\"WWW::Mechanize\" is a subclass of LWP::UserAgent, whatever works on \"LWP::UserAgent\" should work\non \"WWW::Mechanize\". See the lwpcook man page included with the libwww-perl distribution.\n",
                "subsections": []
            },
            "BASICS": {
                "content": "",
                "subsections": [
                    {
                        "name": "Launch the WWW::Mechanize browser",
                        "content": "use WWW::Mechanize;\n\nmy $mech = WWW::Mechanize->new( autocheck => 1 );\n\nThe \"autocheck => 1\" tells Mechanize to die if any IO fails, so you don't have to manually\ncheck. It's easier that way. If you want to do your own error checking, leave it out.\n"
                    },
                    {
                        "name": "Fetch a page",
                        "content": "$mech->get( \"http://search.cpan.org\" );\nprint $mech->content;\n\n\"$mech->content\" contains the raw HTML from the web page. It is not parsed or handled in any\nway, at least through the \"content\" method.\n"
                    },
                    {
                        "name": "Fetch a page into a file",
                        "content": "Sometimes you want to dump your results directly into a file. For example, there's no reason to\nread a JPEG into memory if you're only going to write it out immediately. This can also help\nwith memory issues on large files.\n\n$mech->get( \"http://www.cpan.org/src/stable.tar.gz\",\n\":contentfile\" => \"stable.tar.gz\" );\n"
                    },
                    {
                        "name": "Fetch a password-protected page",
                        "content": "Generally, just call \"credentials\" before fetching the page.\n\n$mech->credentials( 'admin' => 'password' );\n$mech->get( 'http://10.11.12.13/password.html' );\nprint $mech->content();\n"
                    }
                ]
            },
            "LINKS": {
                "content": "",
                "subsections": [
                    {
                        "name": "Find all image links",
                        "content": "Find all links that point to a JPEG, GIF or PNG.\n\nmy @links = $mech->findalllinks(\ntag => \"a\", urlregex => qr/\\.(jpe?g|gif|png)$/i );\n"
                    },
                    {
                        "name": "Find all download links",
                        "content": "Find all links that have the word \"download\" in them.\n\nmy @links = $mech->findalllinks(\ntag => \"a\", textregex => qr/\\bdownload\\b/i );\n"
                    }
                ]
            },
            "ADVANCED": {
                "content": "",
                "subsections": [
                    {
                        "name": "See what will be sent without actually sending anything",
                        "content": "$mech->addhandler(\"requestsend\", sub { shift->dump; exit; });\n$mech->get(\"http://www.example.com\");\n"
                    }
                ]
            },
            "SEE ALSO": {
                "content": "WWW::Mechanize\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Andy Lester <andy at petdance.com>\n",
                "subsections": []
            },
            "COPYRIGHT AND LICENSE": {
                "content": "This software is copyright (c) 2004 by Andy Lester.\n\nThis is free software; you can redistribute it and/or modify it under the same terms as the Perl\n5 programming language system itself.\n",
                "subsections": []
            }
        }
    }
}