Download file from WWW

HMG Samples and Enhancements

Moderator: Rathinagiri

RPC
Posts: 281
Joined: Fri Feb 10, 2017 4:12 am
DBs Used: DBF

Re: Download file from WWW

Post by RPC »

Hi mlnr
Thanks for the code. It works !!!
I can download from the net now :D
I have another problem. I want to download some information from the web page.
It means I have to "read" the page from the program and download that information.
Is it possible :?:
Thanks once again for your help.
hmgaams57
Posts: 129
Joined: Mon Feb 27, 2017 10:00 am

Re: Download file from WWW

Post by hmgaams57 »

Hi mlnr
The program works fine but it would be even better
if there is way to add a progress bar and the ability
to resume downloads without starting from the beginning
after interruption.
mlnr
Posts: 126
Joined: Fri Aug 28, 2015 1:52 pm
DBs Used: DBF

Re: Download file from WWW

Post by mlnr »

hmgaams57 wrote: Wed Mar 08, 2017 3:47 pm Hi mlnr
The program works fine but it would be even better
if there is way to add a progress bar and the ability
to resume downloads without starting from the beginning
after interruption.
Hi hmgaams57

You can get the file size

Code: Select all

oSoap:getResponseHeader("Content-Length")
and try to watch the download state. Some info here

https://msdn.microsoft.com/en-us/librar ... s.85).aspx
RPC wrote: Wed Mar 08, 2017 3:15 pm Hi mlnr
Thanks for the code. It works !!!
I can download from the net now :D
I have another problem. I want to download some information from the web page.
It means I have to "read" the page from the program and download that information.
Is it possible :?:
Thanks once again for your help.
Hi RPC,

Sorry, i cannot help you. Maybe someone has an information.
Best regards,
Gabor
RPC
Posts: 281
Joined: Fri Feb 10, 2017 4:12 am
DBs Used: DBF

Re: Download file from WWW

Post by RPC »

Hi mlnr
Its OK if you cant help in "reading" webpage
At least now I can download links.
Thank you
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Download file from WWW

Post by edk »

Hi RPC.
Try this: C:\hmg.3.4.3\HARBOUR\contrib\hbtip\tests\loadhtml.prg
But, if you need to read pages from https, you must include SSL suport

Code: Select all

#require "hbssl"
REQUEST __HBEXTERN__HBSSL__

IF !tip_SSL()
	MsgStop("Required SSL")
     Return
ENDIF
oHttp := TIPClientHTTP():new( "https://www.google.com/search", .F. )
You need also in hbc:

Code: Select all

libs=hbssl
libs=libeay32
libs=ssleay32
Libs=hbtip
Include in hbp:

Code: Select all

hbssl.hbc
And most important: DLLs
ssl_dll.7z
(566.58 KiB) Downloaded 382 times
Edward.
User avatar
serge_girard
Posts: 3158
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Download file from WWW

Post by serge_girard »

Thx Edward!

Is there a specific folder for the DLL needed or just where the EXE is located?
There's nothing you can do that can't be done...
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Download file from WWW

Post by edk »

Just where EXE is located.
Edward.
RPC
Posts: 281
Joined: Fri Feb 10, 2017 4:12 am
DBs Used: DBF

Re: Download file from WWW

Post by RPC »

edk wrote: Fri Mar 10, 2017 10:29 am Hi RPC.
Try this: C:\hmg.3.4.3\HARBOUR\contrib\hbtip\tests\loadhtml.prg
But, if you need to read pages from https, you must include SSL suport

Code: Select all

#require "hbssl"
REQUEST __HBEXTERN__HBSSL__

IF !tip_SSL()
	MsgStop("Required SSL")
     Return
ENDIF
oHttp := TIPClientHTTP():new( "https://www.google.com/search", .F. )
You need also in hbc:

Code: Select all

libs=hbssl
libs=libeay32
libs=ssleay32
Libs=hbtip
Include in hbp:

Code: Select all

hbssl.hbc
And most important: DLLs
ssl_dll.7z
Edward.
Hi Edwards

Many thanks for the code and description.

I tried to compile, thro IDE, loadhtml.prg but got error BASE/1004 No Exported method: AS

Unfortunately I am quite dumb in understanding all this.

I have to download data from following site
https://www.nseindia.com/products/conte ... x_data.htm

Time period is 10 march 2017 to 10 march 2017 and click Get Data button. Then you will get follo info

Date : 10-Mar-2017 | Open : 8953.70 | High : 8975.70 | Low : 8903.95 | Close : 8934.55 | Shares Traded : 157419999 | Turnover(Rs Cr) : 7385.28

There is also a hyperlink - Download file in CSV format - towards right side corner of the information downloaded. Clicking on this downloads the above information in a CSV file.

It is this information which I want to download. I notice it is a https page. Could you please send a program to download the info in a CSV/text file. I would be very grateful.

Thanks
RPC
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Download file from WWW

Post by mol »

Hi!
Sorry for delay, but last week I was absent without internet.
I have no limitations in type of downloaded file, but this solution has a problem with some proxy servers.
Put a description of error which you geet.

Hi Gabor! Your solution with SOAP is very interesting. Can you add to your code lines, which changes http AGENT to Mozilla or IE?
RPC
Posts: 281
Joined: Fri Feb 10, 2017 4:12 am
DBs Used: DBF

Re: Download file from WWW

Post by RPC »

mol wrote: Sun Mar 12, 2017 6:06 am Hi!
Sorry for delay, but last week I was absent without internet.
I have no limitations in type of downloaded file, but this solution has a problem with some proxy servers.
Put a description of error which you geet.

Hi Gabor! Your solution with SOAP is very interesting. Can you add to your code lines, which changes http AGENT to Mozilla or IE?
Hi mol
Its ok if you couldn't answer earlier. You have been very helpful and I appreciate that.
Following is the screen shot of the error
Error - Download - mol.png
Error - Download - mol.png (32.64 KiB) Viewed 6988 times
I put following url in window
https://www.nseindia.com/content/histor ... av.csv.zip
and save to was a.zip filename, when I click the download button I got above error message.
Thanks
Post Reply