We Recommend

Learning Perl Learning Perl
In this smooth, carefully paced course, a leading Perl trainer teaches you to program in the language that threatens to make C, sed, awk, and the Unix shell obsolete for many tasks. This book is the "official" guide for both formal (classroom) and informal learning. It is fully accessible to the novice programmer.


Posted By

eszpee on 01/14/08


Tagged

script backup csv lwp zoho crm crawl LWPUserAgent


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

melling


Backup all your tables from ZOHO CRM in CSV format


Published in: Perl 


fill your username and password

  1. #!/usr/bin/perl
  2. use strict;
  3. use LWP::UserAgent;
  4. my $silent = 0; # set to 1 for no output on stdout
  5. my $logindata = {
  6. 'j_username' => 'fill in your username (email)',
  7. 'j_password' => 'fill in your password',
  8. 'j_remember' => 'on',
  9. };
  10. my $loginurl = 'http://crm.zoho.com/crm/zohologin';
  11. my $backupurl = 'http://crm.zoho.com/crm/ExportEntity.do';
  12. my @backuptables = qw{Users Leads Accounts Contacts Potentials Campaigns Tasks Events Notes Competitors Products PriceBooks Cases Solutions Forecasts Vendors Quotes SalesOrders PurchaseOrders Invoices};
  13.  
  14. my $ua = LWP::UserAgent->new;
  15. $ua->cookie_jar({ file => "cookies.txt" });
  16.  
  17. print qq{get cookie from frontpage...} unless $silent;
  18. my $devnull = $ua->get('http://crm.zoho.com/crm/login.sas'); #get cookie
  19. print qq{done.\n} unless $silent;
  20.  
  21. print qq{login as $$logindata{'j_username'}...} unless $silent;
  22. my $loginresponse = $ua->post($loginurl, $logindata);
  23. print qq{done.\n} unless $silent;
  24.  
  25. foreach my $whichtable (@backuptables) {
  26. print qq{exporting $whichtable.csv...} unless $silent;
  27. my $backupdata = {
  28. 'module' => $whichtable,
  29. };
  30. my $backuptable = $ua->post($backupurl, $backupdata);
  31. open (KI, ">$whichtable.csv");
  32. print KI $backuptable->content;
  33. close (KI);
  34. print qq{done.\n} unless $silent;
  35. }

Report this snippet 

Comments

RSS Icon Subscribe to comments
Posted By: eszpee on January 18, 2008
Posted By: eszpee on January 18, 2008

You need to login to post a comment.