+ Reply to Thread
Results 1 to 6 of 6

I want to scrape data from a webpage that is a pdf

  1. #1
    Registered User
    Join Date
    01-14-2021
    Location
    Saskatoon, Saskatchewan
    MS-Off Ver
    Excel 2019
    Posts
    20

    I want to scrape data from a webpage that is a pdf

    I want to scrape data from a webpage that is a pdf.

    Specifically, I want the Weaning Pigs (U.S. Total Composite Weighted Average Price per Head) from the following site:

    HTML Code: 
    The code that I have written does not work when it hits
    Please Login or Register  to view this content.
    so I am guessing that I should be referring to this as a pdf rather than an IE.document, but, I don't know how.

    I have also attached the Excel workbook that I have written. Thanks for your help!

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

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,860

    Re: I want to scrape data from a webpage that is a pdf

    You can easily achieve this by using Power Query which is called Get and Transform and found on the Data Tab.

    Open a blank workbook.
    Go to the Data Tab
    Select From Web
    Input your web address you wish
    Select the table you wish to import from the list provided.
    Select Load.

    No need for VBA as this is what this application is designed to do.

    FYI
    Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

    It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

    - Follow this link to learn how to install Power Query in Excel 2010 / 2013.

    - Follow this link for an introduction to Power Query functionality.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,860

    Re: I want to scrape data from a webpage that is a pdf

    I didn't know which table you wished to review. I have loaded all to this workbook.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    01-14-2021
    Location
    Saskatoon, Saskatchewan
    MS-Off Ver
    Excel 2019
    Posts
    20

    Re: I want to scrape data from a webpage that is a pdf

    Thanks for getting back to me.
    I should have specified that I have already figured out how to do that in PowerQuery but since I am doing 52 sheets per year, I was looking to automate the function via VBA.
    The only table that I am looking for is the last one (early weaned and feeder pigs).

    Column1 Formula and Cash Low, US$/Head Formula and Cash High, US$/Head Wtd Avg Price, US$/Head Wtd Avg Price, C$/Head
    Early Weaned (10-12 lb) 39.66 63 49.06 62.83
    Feeder Pigs (40 lb) 59 72 67.38 86.29


    So, is there a way that I could import an entire pdf directly from the website? Then I would just take the last table and move the data to a separate sheet and then automatically repeat.

    Thanks again

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,860

    Re: I want to scrape data from a webpage that is a pdf

    You could create a parameter for the date in Power Query that would return the particular week you wish to scrape.

  6. #6
    Registered User
    Join Date
    01-14-2021
    Location
    Saskatoon, Saskatchewan
    MS-Off Ver
    Excel 2019
    Posts
    20

    Re: I want to scrape data from a webpage that is a pdf

    Thanks for the suggestion.
    I started a routine by recording a Macro and then started trying to modify it.

    What I want to do is to select the first website in the list on the "Websites" sheet, then have the routine go to that site and select the last table on the site and paste it to the respective location on my "USDA Feeders Quarterly" sheet. Then I would like for it to delete the sheet that was created by the Macro.
    Then I would like to repeat the process for the next website on the list in the "Websites" sheet and for it to paste the info into the rows bellow what was last pasted. Until I run out of websites in the column.

    This is what I have come up with so far:

    Option Explicit

    Please Login or Register  to view this content.
    I have attached a Excel workbook and as you can see, I am being a total "Script ******" and trying to borrow from an old routine that I use for other sites.

    Thanks for your help
    Attached Files Attached Files

+ 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. Macro to scrape data off webpage
    By chrisellis250 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-11-2017, 04:41 AM
  2. [SOLVED] Scrape page source from webpage
    By abousetta in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 12-22-2016, 05:42 PM
  3. Replies: 0
    Last Post: 11-13-2015, 05:42 AM
  4. Scrape webpage script needs adjustments:)
    By wzshop in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-24-2015, 06:41 AM
  5. Data Scrape from webpage
    By arnoldchadd in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-16-2014, 07:31 AM
  6. [SOLVED] Web Scrape "Name" from webpage based on URL in Column A
    By Brawnystaff in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-10-2014, 04:52 PM
  7. Scrape Webpage in Access
    By astradford in forum Access Tables & Databases
    Replies: 0
    Last Post: 07-23-2012, 07:34 PM

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