Unix/Linux Go Back    


Programming Post questions about C, C++, Java, SQL, and other programming languages here.

Download http picture using C++

Programming


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 01-12-2016   -   Original Discussion by emily
emily's Unix or Linux Image
emily emily is offline
Registered User
 
Join Date: Sep 2012
Last Activity: 12 January 2016, 3:06 AM EST
Location: Switzerland
Posts: 158
Thanks: 58
Thanked 1 Time in 1 Post
Download http picture using C++

Dear all,
I am working on writing the script which can read a file (having the html path for some pictures) and download those picture in the given local directory. Please find my iniatitve here, however I am still not able to figure out the 'download' command.
Any help is appreciated.

thanks,
emily


Code:
#include <iostream>
#include <sstream>
#include <string>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

void help() {
  cout << " You must provide one input parameters: " << endl;
  cout << "   1) Name of File containing donlwoad path" << endl;
  exit(0);
}


main(int argc, char *argv[]) {
  if (argc < 2) help();
  string InFile   = argv[1];
  ifstream FileToRead(InFile.c_str());

  // debug step                                                                                                                                                                                                 
  if(!FileToRead.is_open()) {
    cout << "Problem opening the file. Program terminating." << endl;
    exit(EXIT_FAILURE);
  }

  std::string line;
  //  while(!FileToRead.eof()) {                                                                                                                                                                                
  while(std::getline(FileToRead, line))
    {
      FileToRead >> line;
     wget line;                                                                                                                                                                                              
    }
}

Sponsored Links
    #2  
Old Unix and Linux 02-03-2016   -   Original Discussion by emily
Corona688's Unix or Linux Image
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 13 December 2017, 10:16 AM EST
Location: Saskatchewan
Posts: 22,546
Thanks: 1,159
Thanked 4,286 Times in 3,955 Posts

Code:
system("wget 'http://url'");

You can feed it a string like system(str.c_str());
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
File download from HTTP::DAV smr_rashmy Shell Programming and Scripting 0 05-10-2011 05:11 AM
sending http url through http socket programming.. senkerth Shell Programming and Scripting 4 12-16-2010 05:32 AM
How to download X bytes from a file using ftp or http? learn more Shell Programming and Scripting 5 07-17-2009 10:49 AM
Coomand to download from HTTP(URL) skm123 UNIX for Advanced & Expert Users 4 08-24-2006 10:56 PM
GCC via Http-Download? cyberbloodgoat UNIX for Dummies Questions & Answers 5 10-09-2001 02:42 AM



All times are GMT -4. The time now is 04:12 AM.