Forum

Create weather fore...
 
Notifications
Clear all

Create weather forecasts with just reading a WEB Page

13 Posts
2 Users
0 Reactions
167 Views
(@a-maurizio)
Posts: 214
Reputable Member
Topic starter
 

Hello Again to All You, I am Always A.Maurizio
My New Problem and This:
On an Excel sheet I tried to extrapolate the reading of a Web Page; As for the weather forecasts.
I would say that for some Verses I have also succeeded; Except for the Fact that does not appear as I would have Waited for Me.
You could have a Look!
I claim that the final result after pushing the button I placed on Sheet 1 is located in Sheet 10.
While in Reality I Want It Like It Sew In Sheet 11
Thank you for all the help you will give me about Sincerity Greetings from A.Maurizio

 
Posted : 05/06/2017 7:17 am
(@catalinb)
Posts: 1937
Member Admin
 

Hi A.Maurizio,

Your code will always add a new sheet and a new connection every time you use that button. Soon, you will have hundreds of connections.

Use the existing connection from Sheet10, delete all other connections, there is no need to create another connection to the same site In fact, you don't even need a code, add a connection to that webpage manually, then just refresh it when you want. Use a simple code to refresh that sheet connection (it is set to refresh on file open, but you can use a code to update whenever you want)

Put the code in Sheet10 module:

Sub RefreshConnection()
    Range("A1").QueryTable.Refresh BackgroundQuery:=False
End Sub

To take the downloaded data into Sheet11, you have to start writing code, it's not an easy code. You need to be able to switch images according to weather data, and so on. It might be easier to simply look at the website, I can see no use of spending lot of time to download data and writing the codes to organize the results.

 
Posted : 07/06/2017 1:28 am
(@a-maurizio)
Posts: 214
Reputable Member
Topic starter
 

Hello Catalin Bombea thank you for your Tip for both the images and the written variant.
Today:
At least you can not interrogate the Web Page Sheet so that when I insert a desired location in a cell; It can bring me at least the still images for that location.
And the various reports of current forecasts as you can see on the site.
To me it is enough as it is seen in this Image:

Previsioni.PNG
[Url = https: //postimg.org/image/sr9bfbiq1/] [img] [/ img] [/ url]

Thank you for all the help you want to give me on Sincere Greetings from A.Maurizio

(P.S) But if for better use and less time for you, if you want me, it would be good if you set everything as you can see on the webpage shown by the program Thank you

 
Posted : 07/06/2017 7:41 am
(@catalinb)
Posts: 1937
Member Admin
 

Hope someone will have the time to help you, what you want is very time consuming and I can't help you, don't have enough time.

There are many options, to use power Query to connect to a good data source for weather services, or even Power BI.

I'm afraid that on any forum, nobody writes complete applications, most of the work must be user's work, we can help you with small fixes and pointing you in the right direction.

Regards,

Catalin

 
Posted : 07/06/2017 3:44 pm
(@a-maurizio)
Posts: 214
Reputable Member
Topic starter
 

Hello Catalin Bombea, you are right to speak of the time at your disposal.
But maybe in my little boy I came back to fight because I created this list, though not having big anomalies; It continues to make me mistake on all sides and I do not understand why.
You would not be able to make it work.
My Procedure and Practice This:

  Private Sub CommandButton1_Click() Dim WS As Worksheet: Set WS = activeSheeet WS.Range("theDate").Value = "" WS.Range("higtTemps").Value = "" WS.Range("LowTemps").Value = "" Dim DelShape As Shape For Each DelShape In WS.Shapes If DelShape.Type = msoAutoShape Then DelShape.Delete Next DelShape Dim Req As New XMLHTTP Req.Open "Get", "https://www.worldweatheronline.com/", False Req send 'MsgBox Req.responseText Dim Resp As New DOMDocumentType Resp.LoadXML Req.responseText Dim weather As IXMLHttpRequestEventTarget Dim I As Integer Dim wShape As Shape Dim thisCell As Range For Each weather In Resp.getElementsByTagName("weather") I = I + 1 'Debug.Print "Text" WS.Range("theDate").Cells(1, I).Value = weather.SelectNodes("Date")(0).Text WS.Range("hightemps").Cells(1, I).Value = weatherselectNodes("TempMaxF")(0).Text WS.Range("Lowtemps").Cells(1, I).Value = weatherselectNodes("TempMinF")(0).Text Set thisCell = WS.Range("weatherpictures").Cells(1, I) Set WS.Shape = WS.Shapes.AddPicture(weather.SelectNodes _ ("weatericonUrl")(0).Text.msoFalse, msoCTrue, _ thisCell.Left, thisCell.Top, yhiscell.Width, _ thisCell.Height) Next weather End Sub

Ripeto a me da Errore sin dall'inizio, però magari con il vostro aiuto riusciamo a mettere in sieme tutti i pezzi

Grazie infinite da A.Maurizio

 
Posted : 08/06/2017 10:20 am
(@catalinb)
Posts: 1937
Member Admin
 

Many errors indeed, mostly syntax errors, like WS=ActiveSheeet (note the 3 e)

There is a reference needed in VB Project to Microsft XML .

It's a matter of attention, you had wrongly spelled defined names. It is obvious that english is not your strongest point, even reading your messages is very confusing.

I fixed the sintax errors, your codes will run now, but will return nothing and you will have to find why.

You can find other methods, much cleaner.

For example, I used a free API service from https://www.apixu.com/

After you signup for a free plan, you will receive an API key, paste that key into the API Key table from Location sheet, in the attached Weather 7 days Forecast.xlsx.

There is no value at this moment in the API Key table (I deleted my key), the refresh will fail until you paste there the key obtained from the site above.

Then, all you need to do is to change the location in the Location table (it is Milano, Italy now), change to whatever location you want. As you will see on their site, you can add not only city names, latitude, longitude, zip codes are accepted as locations. To get the new data based on the location you entered, just go to data tab and press Refresh All button.

On the first use of the file, you should choose the privacy settings, select Public from the dropdown.

In the forecast sheet, you will find the data for 7 days, with image links, and all the parameters you want.

You can now write codes to download the images and add them to your desired dashboard.

 
Posted : 08/06/2017 2:23 pm
(@a-maurizio)
Posts: 214
Reputable Member
Topic starter
 

Hi Catalin Bombea I thank you for your support, You fully understand in everything and for everything; Except for a tiny Detail.

If I had your training skills, everything you just said would have been gold molded for me.
But since I am what I am; I love to program; But even if I do this for many years with different languages, it does not mean that it is up to you.

That said: you would not be able to miss your daily commitments (Jobs) Here ...!
A concrete prospect Working on what you just told me, I would be very helpful.
Thanks Greetings from A.Maurizio

 
Posted : 09/06/2017 6:01 am
(@a-maurizio)
Posts: 214
Reputable Member
Topic starter
 

In a nutshell, how would Catalin Bombea
you solve the whole thing, would you like to create a Genre thing on your own?
Thank you for all For the help you will want to give me regards Greetings from Maurizio

 
Posted : 09/06/2017 6:05 am
(@catalinb)
Posts: 1937
Member Admin
 

I prefer to go for the Power Query solution already sent in the previous message. (Weather 7 days forecast.xlsx)

All you have to do is to take the data returned by the queries, and organize it the way you like, with a code.

 
Posted : 09/06/2017 2:22 pm
(@a-maurizio)
Posts: 214
Reputable Member
Topic starter
 

Hi Catalin Bombea No is the best, but I might also be fine as this. But how do I change the desirable location; As I see that there is only written Milan. But did I like Turin for example? How and what should I do to change everything Thank you again for your greetings from A.Maurizio

 
Posted : 10/06/2017 6:57 am
(@catalinb)
Posts: 1937
Member Admin
 

Catalin Bombea said
Then, all you need to do is to change the location in the Location table (it is Milano, Italy now), change to whatever location you want. As you will see on their site, you can add not only city names, latitude, longitude, zip codes are accepted as locations. To get the new data based on the location you entered, just go to data tab and press Refresh All button.

 I think I already sent the instructions to change the location and update data, here it is again.

Instead of typing locations there, you can add a dopdown with your favourite locations.

 
Posted : 10/06/2017 8:30 am
(@a-maurizio)
Posts: 214
Reputable Member
Topic starter
 

Hi Bombea Thank you for all I will try to do what you said to me, too, I see him bad because I do not have your skills.
Anyway, it does not matter: I'm going to see that I'm going to figure out how to target a locality and then I'm using a Windows API to open a single sheet with only one base address, but pointing to telephones, so the page itself will give me the whole.
Even here it will not be a walk, as it will not be the maximum, but it is always better than nothing.
In Alternative I will try to commit myself to using this other method which is this: http://api.ilmeteo.net/index.php?id=wgmmwrhl8811&r=ac

Here is the bees of windows on the site you specified.
Even here it will not be easy but I will try.
Anyway Thank you for all sincere greetings from A.Maurizio

 
Posted : 10/06/2017 1:21 pm
(@a-maurizio)
Posts: 214
Reputable Member
Topic starter
 

Hi Bombea if I do not ask you too much, maybe I would have found the system to satisfy my desire in solving my project on weather forecasts; However, I would clearly have a small request, provided that you may want to help me in all this.
So the problem is this:
Take Good for My Project with Your Contribution You Thou hated me to take away all those initial things that kept me wrong and stopped the program.
Now that's what you say: You who are capable of fixing only these couple of functions are:
1st) Take for Good the Place I Insert in (H1) of the excel sheet.
2 °) Adjust my project so that I can find this location and accordingly I can only see the first Image found.
I'll explain :
Once the site problem has been resolved, the program should link to the site you want to target.
Type ("Turin") then in Cell (B7) present me the only image it finds.
Always in my case going to the site and I focused on the first image I found; Then I did with the right mouse button and in the drop down menu I clicked on (Inspect Item) and I got this code:
"<Svg version =" 1.1 "xmlns =" ​​ http://www.w3.org/2000/svg "> <use xmlns: xlink =" http://www.w3.org/1999/xlink "xlink: href = "# SW3" data = "sp3"> </ use> </ sv>

That said, I think you can do nothing other than directing it to a shape or an Image.picture and the game will be fixed here.
Only that surely you are able to do it I do not.
Without seeing at least one part to solve it all.
Please do not angry with me I would be very much in this project, but without your help I would not know how to proceed Thank you for everything The help you will give me.
My project link is this: https://app.box.com/s/eoojl1slv5lrl3ww02e9b737i0b04zs2

Thank you Thank you Thank you Maurizio

 
Posted : 11/06/2017 1:12 pm
Share: