Click here to Login









Download Trading Data using the URL-Script

Updated on 2011-01-25





A download item is composed of one or several URLs. These URLs define the downloading process.
Some download items use simple processes while others have very complex ones. An example of a complex process is: Login to a page, visit a download page, generate the download link (Download link changes each time), and download data.

A URL-Script is a .Net script that can be assigned to a URL and is executed before browsing this URL.
You can edit/create a URL-Script by clicking on the "Settings" button of a URL row, then clicking on "Create a URL-Script".

URL-Scripts allow you to:

Update the default URL and generate a dynamic URL

Example:
Functions.AddURL("https://www.example.com/download.php", "Downloading...");

Create several URLs to parse

Example:
Functions.AddURL("https://www.example.com/download.php?symbol=A", "Downloading 1/2...");
Functions.AddURL("https://www.example.com/download.php?symbol=AA", "Downloading 2/2...");

The above script creates two URLs, where each URL will be passed to the parser.

Create a URL path (Example: Login Page -> Download Page -> Download Data)

Example:
URLPath path = Functions.CreateURLPath();
path.AddURL("https://www.example.com/login.php?username=xx&password=yy", "");
path.AddURL("https://www.example.com/quotes.php?symbol=A", "");
path.AddURL("https://www.example.com/download.php", "");
Functions.AddURLPath(path);

The URLs added to the path will be used to download the data that is referenced in the last URL. In the above example, the path logins to an account, visits an intermediate page then downloads data.

Browse URLs using a hidden/visible browser

This feature was added recently in QS Trading Software. It allows you to use a browser to download data, parse it and add it into QuantShare.
The reason for using a browser is that sometimes, URL parameters are complex, dynamically updated and very hard to find. In this case, you can specify a series/list of URLs that are used in a Browser to reach the download page and then transfer the downloaded data (CSV, EXCEL, ZIP...) to QuantShare so that it can be parsed and added to your databases.
The whole process is automatic; this means that you will not see the browser and you will not get any dialog box (even when a file is downloaded).

Here is an example:
Functions.Browser.Visible = true;
Functions.Browser.Browse("https://www.google.com/finance/historical?q=NASDAQ:GOOG");
Functions.Browser.Sleep(2000);
Functions.Browser.ClickLink1("Download to spreadsheet");

For this example, I have made the browser visible and added a few seconds delay between requests so you can see what happened.

Other Functions

In the URL-Script, the "Functions" class contains all available functions. After you type "Functions", type "." to display these functions.

Functions.GetValues: Gets the current URL field value. A URL field can be added by clicking on "Fields" in the URL row.
Functions.GetAllValues: Gets all values that will be passed to the URL field. Example: If the URL field type is set to "Symbol", then this function will get all symbols that are used by this download item.
Functions.SetValues: Updates a URL field value.

The option "Load the URL-Script only once" instructs the application to execute the URL only once. This means that even if there is a "Symbol" and "Date" fields associated with the URL, this URL will be executed only once (For the first symbol and first date).
The URL-Script can then be used to dynamically generate URLs based on "Symbol" and "Date" values.











no comments (Log in)

QuantShare Blog
QuantShare
Search Posts




QuantShare
Recent Posts

Lock, Link and Undock your Charts
Posted 474 days ago

QuantShare
Previous Posts

QS Trading Software: Global Script
Posted 3250 days ago


More Posts

Back







QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright 2019 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.