Download file from WWW

HMG Samples and Enhancements

Moderator: Rathinagiri

edk
Posts: 997
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 434 times
Edward.
User avatar
serge_girard
Posts: 3308
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: 997
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: 304
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: 3774
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: 304
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 8035 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
edk
Posts: 997
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Download file from WWW

Post by edk »

hbtip library itself does not support https.
You need to add support for SSL to be able to use https protocol.
edk
Posts: 997
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Download file from WWW

Post by edk »

mol wrote: Sun Mar 12, 2017 6:06 am Can you add to your code lines, which changes http AGENT to Mozilla or IE?
Marku add after oSoap:open

Code: Select all

oSoap:setRequestHeader ("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)")
edk.
edk
Posts: 997
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Download file from WWW

Post by edk »

Hi RPC.
RPC wrote: Sat Mar 11, 2017 6:49 pm (...) Could you please send a program to download the info in a CSV/text file. I would be very grateful. (...)
Here is a program that retrieves data from the NSEIndia.
NSE.7z
(1.82 MiB) Downloaded 350 times
Unfortunately I can't download the file "CSV" (from the link in the corner), because the link executes the script on the server, I can't run it.
However, I'm thinking that the downloaded html table by my program will allow you to easily obtain the datas.
nse.png
nse.png (19.83 KiB) Viewed 7597 times
PS. Especially in the program I used two methods to obtain data to show (teach) how this can be done.
The first method uses OLE, the second uses hbTIP.

Edward.
RPC
Posts: 304
Joined: Fri Feb 10, 2017 4:12 am
DBs Used: DBF

Re: Download file from WWW

Post by RPC »

Hi Edward,
Many thanks for the program. You are just great !. :ugeek:
I can download the index information from nseindia website now. :D
The information is in html format. Can you please tell me a way to read this file and import the information in preferably CSV file. :?:
Thanks
RPC
Post Reply