Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
342 views
in Technique[技术] by (71.8m points)

Excel VBA Simple Web Scraping but table isn't selected with CTRL+A

I have a simple Excel VBA web scraping sub that I have used for a couple of websites just fine.

The main summary is that it goes to the website, then performs:

    While .Busy Or .readyState <> 4: DoEvents: Wend
    ie.ExecWB 17, 0 '// Select All
    ie.ExecWB 12, 2 '// Copy selection

I then paste that into my excel, and extract my data.

The problem is, that on this website: https://www.legalandgeneral.com/investments/funds/prices-and-reports/daily-fund-prices/ The table with all the data isn't selected when I hit ctrl + A, or with ie.ExecWB 17,0 in the code. If I click on the table and then do ctrl + A it does select the data. I tried using a CSS selector to click the table, then run ie.ExecWB 17,0 but it doesn't work.

Any ideas?

Many thanks

Dave

question from:https://stackoverflow.com/questions/65901830/excel-vba-simple-web-scraping-but-table-isnt-selected-with-ctrla

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Both Zwenn and QHarr spotted this, with the table iFrame pointing to 5 different sources.

Hitting 'inspect' on the table, you would see something like this:

<iframe style="border: 0;" src="https://widgets-lgim.huguenots.co.uk/Consumer-> unit-trust-prices-actively-managed-funds" width="1000" height="1900" scrolling="no"></iframe>

So then I found all the other sources by changing the table tab, and inspecting:

https://widgets-lgim.huguenots.co.uk/Consumer-unit-trust-prices-n-unit-trust

https://widgets-lgim.huguenots.co.uk/Consumer-unit-trust-prices-index-tracking-funds

https://widgets-lgim.huguenots.co.uk/Consumer-unit-trust-prices-multi-asset-funds

https://widgets-lgim.huguenots.co.uk/Consumer-unit-trust-prices-fixed-income-funds

https://widgets-lgim.huguenots.co.uk/Consumer-unit-trust-prices-actively-managed-funds

This can now be closed.

Regards


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...