How to grab data from the script protected site with Excel VBA? - php

I can't import data table from the site which contain stock data. I did in MS Excel 2007; Data > Get External Data > From Web > Import as usual but there have no return from sites. When I tried to grab data table from the site its shown a small window massage (screenshot), I think the process redirecting to another link; but ultimate result is zero. I think the page is script protected.
Redirecting massage: "Opening: 'http://www.dsebd.org/latest_share_price_all.php"
Please advice me how could I download ( import) data from such site in my Excel Workbook.
The site original link: http://www.dsebd.org/latest_share_price_scroll_l.php [I want to download data from here]
Thanks in Advance for any support.

It's not problem with Excel.
Website is using iframe-->and denying access to request...
Look for site code by pressing F12. Did it ever worked for you before

The following code will place each trading code, LTP, change and % change on a separate line in the active worksheet.
' open IE, navigate to the website of interest and loop until fully loaded
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.navigate "http://www.dsebd.org/latest_share_price_scroll_l.php"
.Top = 50
.Left = 530
.Height = 400
.Width = 400
Do Until Not IE.Busy And IE.readyState = 4
DoEvents
Loop
End With
If you use F12 to look at the source code, you'll notice that each stock and it's associated data is bracketed by a tagname (in this case "a"). Use this to collect the data for each stock and place the data for all stocks in "Results". Step through "Results" and place each stock on a separate line. Use the replace function to remove a line break so the data appears on 1 line.
Set Results = IE.document.getElementsByTagname("table")(0).getElementsByTagname("a")
x = Results.Length
For y = 0 To x - 1
gg = Results(y).innertext
gg = Replace(gg, Chr(10), "", 1, -1, vbTextCompare)
ActiveCell = gg
ActiveCell.Offset(1,0).Select
Next

Press A1 cell, then data-> http://www.dsebd.org/latest_share_price_scroll_l.php-> click first arrow-> import->ok .....eureka
on cell E1 you will see ur desired thing

Related

ADVISE: Accessing PHP Objects in Internet Explorer from Excel VBA

I am trying to automate an excel upload process we have into our data warehouse. From Excel VBA, I am initiating an IE session to our data warehouse > login with my credentials > then navigate to the page to upload, but this is where I am having my problems.
The URL does not change when navigating this website, it is coded in PHP I believe. Therefore, I need to click the specific image - but I do not know how.
In my code below, I added my comments and the error message I receive when debugging. I also added an image of the website, the button I am trying to hit, and inspect of the element. Please help and thank you all in advance! <3 to Stack Overflow!
Signed, Doug Fresh
Private Sub CommandButton2_Click()
Dim objIE As InternetExplorer
Dim aEle As HTMLLinkElement
Dim ele As Object
Dim y As Integer
Dim result As String
Set objIE = New InternetExplorer
objIE.Visible = True
objIE.navigate "http://kpionline.bitam.com/english/memberlogin.php"
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
objIE.document.getElementById("user_name").Value = "username#bimbo.com" 'not real
objIE.document.getElementById("user_pwd").Value = "Bimbo2017" 'not real
objIE.document.getElementById("Login").Click
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
objIE.navigate "https://kpionline7.bitam.com/artus/genvi_test/LoadStage.php?txtRepositorio=fbm_bmd_0030&txtUser=xxxxxxx&txtPassword=xxxxx"
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
'**************************************************************************
'How do I click this icon???
objIE.document.getElementById("ENL8").getElementsByTagName("img")(0).Click
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
'Please see image for php/js website code
'ERROR: Run-time error '424': Object required
'**************************************************************************
objIE.Quit
End Sub
try objIE.document.getElementById("ENL8").Click

Current exchange rates for Excel

Is there a way to import current exchange rates in MS-Excel and keep them updated?
Excel provides a way of calling a URL and import the response into a cell.
There are several prof. services on the internet but I wanted to make sure that no data is logged and the information provided is up-to-date. And it should be free of charge...
Here is a coding-free solution. You can download data in CSV format from Yahoo Finances and import it to Excel as a query.
How to import the data from Yahoo Finances to Excel?
Go to Data → From Web.
Specify the data URL in the field URL, e.g. for the USD to EUR rate:
http://download.finance.yahoo.com/d/quotes.csv?s=USDEUR=X&f=b
Press Load. The new sheet with the required data will be automatically created.
You can hide the header and the style of the cell by unselecting the Header Row and Banded Rows respectively.
That's all, now you have a cell with the desired data. You can referece to the cell like to any other cell in Excel.
Good to know:
You can manually trigger the data refresh by clicking on Data → Refresh All. For automatic update when a workbook is opened: https://support.office.com/en-US/article/Refresh-an-external-data-connection-in-Excel-2016-for-Windows-1524175f-777a-48fc-8fc7-c8514b984440
The URL in the example above contains the &f=b fragment, which means bid. For the detailed Yahoo Finances query data parameters, please see: http://www.financialwisdomforum.org/gummy-stuff/Yahoo-data.htm
Exchange Rates in Excel
Call the URL http://genia.berlin/usd.php to get the actual exchange rate in comparison to US-Dollar. The accuracy is 4 decimal places. An erroneous call returns an empty result, no error message. One parameter given in ISO 4217 notation, e.g.: http://genia.berlin/usd.php?eur
The information is provided without warranty of any kind!
The step-by-step solution including screenshots can be found here: https://eves.genia.berlin/excelquery_e.html
Create a text file. The name can be freely selected. Please make sure that there is a blank line after the URL.
WEB
1
http://genia.berlin/usd.php?["Currency","Enter currency code (ISO 4217)"]
Selection=EntirePage
Formatting=None
PreFormattedTextToColumns=True
ConsecutiveDelimitersAsOne=True
SingleBlockTextImport=False
DisableDateRecognition=False
DisableRedirections=True
Select a stored request
Start Excel and display the following menu: Data / Get External Data / Run Saved Query ...
Type the location and name of the text file (for example, excelquery.txt) from the previous section.
The query is treated as a formula. The assigned cell can be stored in another worksheet.
Selection of external data
In selecting the properties different settings such as automatic updating can be set when opening the Excel document.
Selection of currency as a parameter
There are three possible ways to select the currency as a parameter.
Input by user (Prompt for value using this string)
Specifying a string, for example EUR (Use this value)
Specifying an Excel cell containing a string (Get the value from
this cell)
Input by user
The user is prompted in a dialog to specify the currency. He can also determine whether the input is to be used again in future updates of the same document.
Next time you call the Excel file a warning is issued. The connection for data retrieval must be confirmed by the user.
Here is the code snipped (PHP) on the server side:
<?php
if ($p= substr ($_SERVER['QUERY_STRING'], 0, 3)) {
$pu= strtoupper ($p);
if (preg_match ('/^(?:
BGN|CHF|CZK|DKK|EEK|EUR|GBP|HRK|HUF|ISK|LTL|LVL|MDL|MKD|NOK|PLN|RON|RSD|RUB|SEK|SKK|TRY|UAH|
BDT|BND|CNY|FJD|HKD|IDR|INR|JPY|KRW|LKR|MVR|MYR|NPR|PHP|PKR|SGD|THB|TWD|VND|IQD|
ANG|ARS|BOB|BRL|CAD|CLP|COP|CRC|DOP|HNL|KYD|MXN|NIO|PEN|PYG|SVC|TTD|UYU|VEF|
BWP|DZD|EGP|KES|MAD|MUR|NAD|NGN|PGK|SCR|SLL|TZS|UGX|XOF|ZAR|ZMK|
AED|AUD|BHD|ILS|JOD|KWD|KZT|LBP|NZD|OMR|QAR|SAR|TND|UZS|YER
)$/x', $pu)) {
$pl= strtolower ($p);
if ($x= simplexml_load_file ("http://xxxxx/$pl.xml", null, LIBXML_NOCDATA)) {
if (preg_match ("/(\d+)\.(\d+)\s*$pu/", (string) $x->channel->item->description, $currency)) {
header ('Content-type: text/plain');
header ('Cache-Control: no-cache, must-revalidate');
echo "$currency[1],$currency[2]"; //Excel braucht Komma statt Punkt
exit;
}
}
}
}
header ('HTTP/1.1 204 No Content', true, 204);

FileMaker - editing container field using php api and Insert from URL script

I am using php api for adding/editing/viewing a FileMaker database. I am using Filemaker pro 14 and FMS 14 in windows environment.
I am having an issue with adding/editing container fields. Tried the solution given in the following link: https://community.filemaker.com/thread/66165
It was success. The FM script is:
Goto Layout[ The layout that shows your container field ]
New Record/Request
Set Variable[$url ; Value:Get(ScriptParameter)]
Insert from URL [Select, No Dialog ; database_name::ContainerField ; $url]
Exit Script
I don't want to add new record. I have several container fields in the layout so it's not a solution to add a record for each one, and I need to be able to modify older records' container fields.
I tried modifying the script as follows:
Go to Layout ["products" (products)]
Go to Record/Request/Page [Last]
Open Record/Request
Set Variable [$url; Value: Get(ScriptParameter)]
Insert from URL [Select, No Dialog; products::brochure; $url]
Exit Script []
note: (Last) parameter is just experimental.
The php script is as follows:
$runscript = $fm->newPerformScriptCommand('products', 'addContainerData', 'http://link_to_uploded_file');
$result = $runscript->execute();
$result returns success, but the file wasn't inserted in the container field.
Somebody pointed to me that to use "Insert from URL" I have to specify a record ID. So I did the follows:
modified the php script to:
$editCommand = $fm->newEditCommand('products', $recordID, $editedData);
$editCommand->setPreCommandScript('addContainerData', 'http://url_to_my_uploaded_file');
$result = $editCommand->execute();
and the FM script (addContainerData) to
Set Variable [$url; Value: Get(ScriptParameter)]
Insert from URL [Select, No Dialog; products::brochure; $url]
Exit Script []
Also the result was success BUT without inserting the file to the container field.
What am I missing? What to do to be able to add container data to new/old records?
A possible workaround is to use PHP functions to encode the file to base 64 and set that value to a text field in FileMaker. Once there, you can have auto enter or a script to take the base 64 value and decode it to a container field. This works well especially for files with smaller file sizes.

Form is not posting while inserting maths equation in ckeditor

I have created a from with 5-6 textareas every one having ckeditor and while we insert equation through editor. It works fine # local but i have got empty post array while using on server.
So any one know about any server permission that might be missing.
For information i am using ckeditor with latex equation editor plugin
here is my equation
81^{1/4}\times9^{3/2}\times27^{-4/3} (3^{4})^{1/4}\times (3^{2})3/2
\times (3^{3})^{-4/3} \because 81=3^{4}, 9=3^{2}, 27=3^{3}
= (3)^{4\times 1/4 }\times (3)^{2\times3/2} \times (3)^{3\times-4/3}\because (a^{m}){n}=a^{mn}
=3^{1}\times 3^{3} \times 3^{-4}
= 3^{1+3-4} \because a^{m}.a^{n}.a^{p} = a(m+n+p)
= 3^(1+3-4)
= 3^{0} = 1 \because a^{0}=1
While i am trying this equation my $post is empty, although if i remove 2or 3 "=" sign it works. I really struck with what happens there
I am working from last two days and done almost every thing i got on web
Please help me

Typo3 +TV not rendering content elements

I have installed typo3, templavoila and mapped a template.
Everything works fine, except my content elements. They just don't appear. They did before I installed templavoila and mapped a template.
Also, when using
10 = RECORDS
10 {
tables = tt_content
source = 9
}
it does not give me any output.
even nothing with:
10 = RECORDS
10 {
tables = tt_content
source = 9
conf.tt_content = TEXT
conf.tt_content.value = TEST
}
Does anyone have a clue as to what I might be doing wrong?
You must include the css styled content static template in your TS template.
In your ts page object you need to assign it to the templavoila object.
# Default PAGE object:
page = PAGE
page.typeNum = 0
page.10 = USER
page.10.userFunc = tx_templavoila_pi1->main_page
Probably the page, where tt_content is situated is not visible to regular visitor ?
In this case, following snippet will help.
10 = RECORDS
10.tables = tt_content
10.source = 9
10.dontCheckPid = 1
Finally we got it to work. Don't know what I did wrong, but I guess I learned not to do it again.
I'll put the "solution" here since someone might find it helpful and lose more than a day over this like I did.
Solution:
copy an existing content element in list mode, pasted it on a page via page mode
This was to test if that would do anything. Guess what, everything worked again. Not only the newly copied element but also ALL other test elements created via different ways on different pages and storage folders.
Thank you all for helping and thinking along.

Categories