Scraping the table data from accuweather website

2019-06-14 20:08发布

问题:

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&#176;/71&#176;</td>
                                                        <td>0 <span class="small">in</span></td>
                                                        <td>0 <span class="small">in</span></td>
                                                    <td>&nbsp;</td>
                                                            <td>93&#176;/71&#176;</td>
                                                </tr>
                                                <tr class="pre">
                                                    <th scope="row">Wed <time>5/2</time></th>
                                                            <td>91&#176;/75&#176;</td>
                                                        <td>0.03 <span class="small">in</span></td>
                                                        <td>N/A <span class="small">in</span></td>
                                                    <td>&nbsp;</td>
                                                            <td>93&#176;/71&#176;</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"><a href="https://www.accuweather.com/en/in/bengaluru/204108/daily-weather-forecast/204108?day=1">Thu <time>5/3</time></a></th>
                                                    <td>93&#176;/72&#176;</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&#176;/71&#176;</td>
                                                </tr>
                                                
                                                                                           
                                    </tbody>

回答1:

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.