+ Reply to Thread
Results 1 to 7 of 7

scraping a webpage for flood info

  1. #1
    Registered User
    Join Date
    02-12-2014
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    4

    scraping a webpage for flood info

    Hi,

    I am looking to scrape the environment agency website for UK flood info, I have a list of 5 postcodes I want to check and I would like it so that excel scrapes the most flood warning info ..


    So if I enter a postcode on the site
    IE http://www.environment-agency.gov.uk...erm=RG21%207GP
    it then shows a flood alert for this area, I would like to grab that particular info (the table in light green).

    The web query tool in excel only grabs the whole page unfortunately - can anyone help please ?

    Many thanks

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: scraping a webpage for flood info

    Hello yarrick22,

    Welcome to the Forum!

    How do you want the information to be arranged on the worksheet?
    Do you have a sample workbook you can post?

    How To Post Your Workbook
    1. At the bottom right of the Reply window, Click the button Go Advanced
    2. At the top of the Your Message Window, in the first row of icons, Click the Paperclip icon.
    3. Click the Add Files button at the top right in the dialog box. This displays the File Manager dialog.
    4. Click the Select Files button at the bottom middle of the dialog.
    5. In the new window Find the file you want to upload, select it, and Click Open.
    6. You will now be back in the File Manager dialog. Click the bottom Middle button Upload File.
    7. Wait until the file has completely uploaded before you exit the File Manager dialog.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    02-12-2014
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: scraping a webpage for flood info

    Hi there, thanks for the nice welcome!

    Hopefully you will find my simple file attached.

    So if you click on a postcode at the moment, it will take you to the appropriate flood agency alert page for that area.

    However, I would like to replace that link with a button and it will update the "flood alert" and "information" columns with scraped data from the webpage (or even instead of a button it will automatically just refresh the webpage when you open it? But maybe that will be nasty if there is lots of postcodes..)
    You can see if you click one of my postcode links, the webpage has the info I want in the two light green cells - I would hope to collect the text (doesnt need to have the picture) and put them in the two columns mentioned.


    The other thing is if you click on the berkshire postcode, it will take you to a page showing the nearest area that is flooded, if this happens I would like to try and copy that link to the "information" column so I could click on it and it would take me to the webpage instead?

    Did i explain well enough?

    Many thanks
    Attached Files Attached Files

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: scraping a webpage for flood info

    Hello yarrick22,

    Thanks for posting the workbook. Do you want just a single button to check each of the post codes in column "C"?

  5. #5
    Registered User
    Join Date
    02-12-2014
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: scraping a webpage for flood info

    Hello,

    I'm not really fussed if it is a single button or I have to press one for each postcode, but yes it is just to check the postcodes and tell me if the area is under floor alert. the flood alerts are "no warning", green, amber etc

    Cheers

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: scraping a webpage for flood info

    Hello yarrick22,

    The attached workbook has a single button that will update the status of all the postcodes. There are 3 status results: Flood Alert, No Warnings, and No Data. Let me know you think.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    02-12-2014
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: scraping a webpage for flood info

    Wow this is very nice indeed!

    One thing became apparent, using postcodes like CF23 8FF: , the webpage will show, click here:

    .. 2 links to 2 further areas nearby, which could actually affect the original postcode - so it should be an alert status like "check nearby".

    It would be better if the displayed information in this case, which is:
    "
    Flood warning search results for postcode CF23 8FF

    The flood warning areas nearest to you are listed below.
    Please select one to view area flood information.
    River Rhymney at Llanrumney

    River Rhymney"


    was put into the furtherinfo column on the excel sheet, retaining the clickable hyperlink/s so that it would take me to the webpage for that suggested area?

    Apart from leaving the sheet, I cant think of another way that would display this extended info in the excel sheet nicely.



    I had a go at it using msgbox to test but almost straight away came to a halt!

    Please Login or Register  to view this content.
    Many thanks again

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Vba code for using webpage ( Tracking Goods c/ment on webpage)
    By satputenandkumar0 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-30-2013, 06:03 AM
  2. Web scraping my site info, help me for a donation to your fav charity.
    By macpof in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-06-2013, 01:19 AM
  3. [SOLVED] Load webpage on TOPMAN website, extract prices from webpage into Spreadsheet
    By AKK9 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-04-2013, 11:49 AM
  4. Scraping info from sharepoint
    By JasonPsychoSO242 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-04-2012, 12:27 PM
  5. Macro to Open webpage, then save webpage as txt file.
    By jasocke2 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-07-2012, 04:25 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1