Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Here is the issue:
First, let's start with the html file that I have used to test the script (WMC.html)
<html> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Testing hyperlink file Downloads</title> </head> <body> <h2>Testing Download of hyperlinked files using WWW::Mechanize::Chrome +</h2> <p></p> Let's try downloading this <a href="/my_Files/csv_File.csv">CSV File</ +a> <br/><br/> </body> </html>
Now here is the Perl script.
#!/usr/bin/perl -w use Log::Log4perl qw(:easy); use WWW::Mechanize; use WWW::Mechanize::Chrome; use strict; my $cookie_dir = 'C:/Users/some_user/AppData/Local/Google/Chrome/User +Data/Default/'; #chrome cookies path #my $mech = WWW::Mechanize::Chrome->new( data_directory => $cookie_dir +); my $mech = WWW::Mechanize->new(); my $uri = URI->new( "" ); $mech->get( $uri ); unless ($mech->success) { my $mesg = $mech->response->status_line; print $mesg; goto FINISH; } my $path = "/path"; my @links = $mech->find_all_links( url_regex => qr/\.csv/i ); my @urls = map { $_->[0] } @links; for my $foo (@urls) { my $filename = $path.$foo; $mech->get($foo, ':content_file'=>$filename); my $file_content = $mech->get($foo); print $file_content->content(); } print "Success\n"; FINISH :
When I use the WWW::Mechanize instance, the script runs fine. It prints and saves the file content to disk.
However, when the WWW::Mechanize::Chrome instance is used I get the following error message:
Cannot navigate to invalid URL -32000 at C:/Perl/perl/site/lib/Chrome/DevToolsProtocol/ line + 490

In reply to Re^9: Need help with WWW::Mechanize and Chrome cookies by bakiperl
in thread Need help with WWW::Mechanize and Chrome cookies by bakiperl

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2023-05-30 01:34 GMT
Find Nodes?
    Voting Booth?

    No recent polls found