Scraping the table data from accuweather website - vba

Hi I want to scrap the data from the table. I need all the weather information for all days
click to see image
Please check this link
https://www.accuweather.com/en/in/bengaluru/204108/month/204108?view=table
Source code:
<tbody>
<tr class="pre">
<th scope="row">Tue <time>5/1</time></th>
<td>91°/71°</td>
<td>0 <span class="small">in</span></td>
<td>0 <span class="small">in</span></td>
<td> </td>
<td>93°/71°</td>
</tr>
<tr class="pre">
<th scope="row">Wed <time>5/2</time></th>
<td>91°/75°</td>
<td>0.03 <span class="small">in</span></td>
<td>N/A <span class="small">in</span></td>
<td> </td>
<td>93°/71°</td>
</tr>
<tr class="today lo calendar-list-cl-tr cl hv" data-href="https://www.accuweather.com/en/in/bengaluru/204108/daily-weather-forecast/204108?day=1">
<th scope="row">Thu <time>5/3</time></th>
<td>93°/72°</td>
<td>0.04 <span class="small">in</td>
<td>0 <span class="small">in</span></td>
<td>
<div class="icon i-17-s"></div>
<p>A thunderstorm in spots</p>
</td>
<td>93°/71°</td>
</tr>
</tbody>

This doesn't really directly answer your question but may be the closest you'll get without adding more information to your question and showing that you're making an effort to solve this on your own, by including some code in your question. Or maybe this will work better for you:
Why scrape a site that is willing to practically "hand you" the data, in an easier to handle format, for free?
Accuweather (like many sites) has an API which is free for home use (free up to 50 calls per day) Here is a link.
However (as a big weather & data geek) I much prefer DarkSky Weather API, which allows up to 1000 calls a day for free and (depending on where you're interested in querying) is the most accurate I've seen. (H The get the data from their own sources combined with everything else they can get their hands on (Here is a link.)
I have an Access DB that, for over a year now, has bee automatically opening itself every 8 hours (with Windows Task Scheduler) and querying detailed weather 10 days into the future and 3 days into the past, seeking weather trends and ultimately doing a pretty good job of predicting my home heating costs.
In the USA (where I am not) they even claim the most accurate forecasts down the square-yard, down to the minute.
"It's going to rain this afternoon from 1:17pm until 2:05pm at an average intensity of 0.6mm/hr."
Plus, DarkSky is the only one with an optional Emoji Weather Map. Not very useful but always good for a chuckle. lol
Just for fun, here's your area tomorrow... split down the middle there eh? (They do have real data too.)
Anyway it's worth checking out - but as #Peh indicated, you can't expect all the work to be done for you.

Related

Moving Table Data in a Table Structure Up

<tr>
<th>Photo</th>
<th>Description</th>
<th>Price</th>
</tr>
<tr>
<td>
<img src="images/square.png" alt="box" width="70px" />
</td>
<td class="description">The Rhodes piano is an electro-mechanical piano,
invented by Harold Rhodes during the fifties and later manufactured in a number
of models, first in collaboration with Fender and after 1965 by CBS. It employs
a piano-like keyboard with hammers that hit small metal tines, amplified by
electromagnetic pickups.
</td>
<td id="price">$1400</td>
</tr>
</table>
What I am trying to achieve here is for the $1400 price range to line up with the first line of text in the paragraph. I will have two more of these tables that look exactly the same. I have learned that when entering table data; the data will be in the center of the box. What I think works is giving the price range a class and moving them up using padding-bottom by 55px. I was jsut wondering if there was a better way to move up the price range?

Aurelia Possible Memory Leak

I have a table template that is leaking I have pinpointed the code causing the issue to a single line.
<tbody>
<tr repeat.for="row of workListData.rows" click.delegate='resultItemClick($event, row)'>
<td repeat.for="col of workListData.columns">
<template if.bind='col.name === "isChecked"'>
${col.label}
</template>
<template if.bind='col.name !== "isChecked"'>
**${row.Properties[col.name]}**
</template>
</td>
</tr>
</tbody>
${row.Properties[col.name]}
This is the line of code causing the issue this line takes the current row and uses the column name to access the value of the column
enter image description hereOk it seems aurelia is leaking when I have nested repeat.for
Leaks
<tr repeat.for="row of workListData.rows" click.delegate='resultItemClick($event, row)'>
<td repeat.for="col of workListData.columns">
</td>
</tr>
Does not leak
<tr repeat.for="row of workListData.rows" click.delegate='resultItemClick($event, row)'>
</tr>
Its definitely coming from nested repeat problem is if I simplify the code IE remove web services etc its work as expected
One of my colleagues has noticed something interesting commenting out a different template controller also stops the leak seems its not fussy which controller gets commented out.
Finally located the leak it seems I had a couple however one thing for sure is aurelia seems to have a very bad tendency to leak if you do this in a template
${row.Properties[key]}
Not sure if that is supported though
I now instead pass the object and key to a function and return the value which solves the issue

Looping over two-dimensional array containing objects in Vue.JS

The problem
In Vue, I'm passing an array called issues. The array contains (at present) two objects, but can contain infinite amounts of objects. Every object then has another array named issues, nested inside of it.
The issue is that when I need to display the data, I find that I can't seem to reach the inner "issues" section of it.
I can loop through the first array like so:
<tr v-for="issue in issues" track-by="id">
But that only lets me see the first two objects. I then tried:
<tr v-for="issue in issues" track-by="id">
<td>
<div class="btn-table-align" v-for="issue_title in issue.issues">
#{{ issue_title.title }}
</div>
</td>
</tr>
Which lets me access the sub-elements, but doesn't generate enough rows. I then tried looping over it AGAIN, like so:
<div v-for="first in issues" track-by="id">
<tr v-for="issue in first" track-by="id">
<td>
<div class="btn-table-align">
#{{ issue.id }}
</div>
</td>
</tr>
</div>
But, alas - it generates no rows at all when I do that.
I'd basically need a way to run a "issue in issues", then another for the results and THEIR direct children. The only issue is - I can't figure out how to do it, and Vue won't respond to any of the above attempts! I find a severe lack of documentation on two-dimensional arrays in Vue as well, which has me confused further.
Can anyone shed some light on this? Is it possible, or do I need to adjust the data sent to Vue differently?
To help, I shot an image of an example structure: http://i.imgur.com/6Oz67R9.png
This was a typical 5am question, where I now realize that the data I'm passing makes no sense - it should be the other way around. The actual issues should be in the first array, and the subarray should contain affected servers.

Mixing table header <th> and table data <td> cells in a single table row <tr>

I have a set of survey questions each of which I am arranging in a single row table. I want the first entry to serve as a prompt and have been using <th> for that cell, as in:
<table style='width:100% table-layout:fixed;border-collapse: collapse;'>
<tr>
<th style='width:40%'>
<b>How long were you on active surveillance?</b>
</th>
<td style='width:10%;'>f3_watchtime_num</td>
<td style='width:5%'></td>
<td style='width:50%;>f3_watchtime</td>
</tr>
</table>
It seems to work OK but I have some reservations and questions about mixing <th> and <td> cells in a single <tr>:
Is this HTML5 Standards compliant? (Is there a W3C document that allows or prohibits this practice?)
Are there any downsides to this practice?
Thanks,
David
1. Is this HTML5 Standards compliant? (Is there a W3C document that allows or prohibits this practice?)
W3C tr reference says it's content model can contain:
Content Model:
Zero or more td, th, and script-supporting elements
https://www.w3.org/TR/html5/tabular-data.html#the-tr-element
While your usage isn't very common, there isn't anything in W3C that forbids it.
2. Are there any downsides to this practice?
As for the use of th and td together, its accepted by W3C provided they are children of a tr element.
However, if you are displaying tabular data, (i.e. your survey results are data) using a table is fine. If you are using the table for layout purposes, you should use a CSS based layout instead.
The recommendation of W3C is avoid to use tables for layouts. It is valid only for displaying ordered data, but that's not your case. You can achieve the same with <div> and will be semantically correct.
Other thing is your question about mixing. I think if you don't write <tbody> and <thead> tags, you don't separate the content for the headers in the table, so that's correct because there aren't <td> tags inside a <thead> and there aren't <th> tags inside a <tbody>.
However, it's better practice if you don't use tables for this purpose.

Handling of dynamic ids through selenium webdriver

Automate an application through selenium where id changes dynamically.how can i handle this.Pls help me..
HTML code is:-
<table border="0" cellpadding="0" cellspacing="0" width="1000px">
<tbody><tr id="ctl00_ctl00_MainContent_CarQuoteMainContent_rpQuotes_trSelectedQuote_0">
<td align="center" valign="middle" width="12%">
<input id="ctl00_ctl00_MainContent_CarQuoteMainContent_rpQuotes_chkCompare_0" name="ctl00$ctl00$MainContent$CarQuoteMainContent$rpQuotes$ctl00$chkCompare" type="checkbox">
</td>
In both the cases ( and ), I assume that the first part of the ID is unique. So you can use something like this.
//tr[contains(#id,'ctl00_')] and for input field //input[contains(#id,'ctl00_')].
Those don't look like dynamic IDs, but rather non-content-specific row IDs for elements in a list.
If that's the case, you can't immediately ascertain 'This row element is displaying data for MyCarQuotes.com' from this information alone as there's nothing in the HTML shown to base that query on.
If there's something in the rows you can use to 'identify' the content (eg a company name) - and you have a specific 'thing' you want to interact with - you could encapsulate the lookup and do something like
CheckboxForQuoteFromCompany("MyCarQuotes.com").Click();
If you're able to post more of the HTML (at least a full row), and more importantly the intention of your test, we may be able to be of more help.