Download file from WWW

HMG Samples and Enhancements

Moderator: Rathinagiri

RPC
Posts: 94
Joined: Fri Feb 10, 2017 4:12 am
Has thanked: 22 times
Been thanked: 2 times

Re: Download file from WWW

Post by RPC » 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.

hmgaams57
Posts: 61
Joined: Mon Feb 27, 2017 10:00 am
Been thanked: 1 time
Contact:

Post by hmgaams57 » 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.

mlnr
Posts: 54
Joined: Fri Aug 28, 2015 1:52 pm
Location: Hungary
Has thanked: 19 times
Been thanked: 5 times

Post by mlnr » Thu Mar 09, 2017 1:22 pm

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: 94
Joined: Fri Feb 10, 2017 4:12 am
Has thanked: 22 times
Been thanked: 2 times

Post by RPC » Fri Mar 10, 2017 7:26 am

Hi mlnr
Its OK if you cant help in "reading" webpage
At least now I can download links.
Thank you

edk
Posts: 114
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 28 times
Been thanked: 53 times

Post by edk » 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
(566.58 KiB) Downloaded 26 times
Edward.

User avatar
serge_girard
Posts: 1749
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 226 times
Been thanked: 45 times
Contact:

Post by serge_girard » Fri Mar 10, 2017 11:06 am

Thx Edward!

Is there a specific folder for the DLL needed or just where the EXE is located?

edk
Posts: 114
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 28 times
Been thanked: 53 times

Post by edk » Fri Mar 10, 2017 12:27 pm

Just where EXE is located.
Edward.

RPC
Posts: 94
Joined: Fri Feb 10, 2017 4:12 am
Has thanked: 22 times
Been thanked: 2 times

Post by RPC » Sat Mar 11, 2017 6:49 pm

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: 2752
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 95 times
Been thanked: 36 times
Contact:

Post by mol » 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?

RPC
Posts: 94
Joined: Fri Feb 10, 2017 4:12 am
Has thanked: 22 times
Been thanked: 2 times

Post by RPC » Sun Mar 12, 2017 8:40 am

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 151 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

Who is online

Users browsing this forum: PERICO2017 and 2 guests