Extracting html elements in a given region?
-
10-07-2019 - |
Question
Given a region defined by a rectangle and a url, is there any way to determine what elements lie within the given rectangle on the page at the given url?
EDIT: Screen resolution, Font size, etc.. can all be set to reasonable defaults.
Solution
- Get the document from the URL.
- Render it (in a browser).
- For each element in the browser's DOM:
- Get the rectangle[s] occupied by the element.
- Compare the element's rectangle with the rectangle you're interested in.
OTHER TIPS
Perhaps, but you would nee to use a full browser rendering engine. I'd recommend the QT implementation of webkit. It is fairly simply to get going.
Some things you need to consider:
- Screen Resolution.
- Browser Font size.
- Browser Type.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow