简体   繁体   中英

Access denied to download file using libcurl

I am developing an application in qt c++ which download the file from website and process it.

I have used libcurl in qt for downloading the file.

I am downloading the file using link example: " http://www.nseindia.com/content/historical/EQUITIES/2014/OCT/cm01OCT2014bhav.dbf.zip "

When I download this file using browser It gets downloaded. But when I download the file using libcurl, then I get reply in console as access denied

I have tried to download some other files like curl libbrary using libcurl form the same program just replacing the url, and it worked fine then. Example : " http://mirrors.kernel.org/sources.redhat.com/cygwin/x86_64/release/curl/curl-7.37.1-1.tar.xz "

Is there anything need to use in the libcurl like agents or like that? Or its server functionality to disallow the automated downlaod?

Thank you.

Try something like (specify user agent and redirect to a file, this is on your linux shell)

curl -A "Mozilla/4.0" http://www.nseindia.com/content/historical/EQUITIES/2014/OCT/cm01OCT2014bhav.dbf.zip >yourfile.dbf.zip

Edit: Just realized that you are downloading it through your c++ code. The above example shows that the server hosting the file has permission based on user-agent. So, in your code, you need to specify a dummy user agent something like "Mozilla/4.0" that should return the buffer of the file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM