Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Hi , i am using Selenium::Remote::Driver; module to download some files from webpage, Actually when i click the link in the webpage i will get an zip file , as i cannot save it directly, i am using get_page_source function to get that page and printing (putting ) in file and after that download i am renaming that file to .zip file , but when i open the file i am getting error that file is damaged , so how i can download the file without damging , please help me , i have attached code below please help me how to solve the issue

use Selenium::Remote::Driver; @webelements=$driver->find_elements("input","tag_name"); foreach $elemnt (@webelements){ sleep(5); $string = $elemnt->get_attribute('src'); print "The string is [$string] \n"; if ( $string && $string =~ /disk25.gif/i){ print "one lement found \n"; $elemnt->submit(); sleep(5); #$elemnt->click(); my @handles = $driver->get_window_handles; print "handles in last loop @handles ".@handles; open (F1,'>C:\Users\u0156151\Desktop\final'); open (FS,'>C:\Users\u0156151\Desktop\finalfile'); #$F="Z$count"; binmode FS; print FS $driver->get_page_source(); print F1 $driver->get_page_source(); last; $count++; } }

so after running the above code i will get two files final and finalfile , when i rename them to final.zip and finalfile.zip the zip file is getting corrupted


In reply to Selenium get_page_source function by ragilla

Title:
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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-23 10:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found