Note that there are some explanatory texts on larger screens.

plurals
  1. PORemotely Scrape Page and Get most Relevant title or Description for Images with XPath
    primarykey
    data
    text
    <p>What I'm looking at doing is essentially the same thing a Tweet button or Facebook Share / Like button does, and that is to scrape a page and the most relevant title for a piece of data. The best example I can think of is when you're on the front page of a website with many articles and you click a Facebook Like Button. It will then get the proper information for the post relative to (nearest) the Like button. Some sites have Open Graph tags, but some do not and it still works.</p> <p>Since this is done remotely, I only have control of the data that I want to target. In this case the data are images. Rather than retrieving just the <code>&lt;title&gt;</code> of the page, I am looking to somehow traverse the dom in reverse from the starting point of each image, and find the nearest "title". The problem is that not all titles occur before an image. However, the chance of the image occurring after the title in this case seems fairly high. With that said, it is my hope to make it work well for nearly any site.</p> <p>Thoughts:</p> <ul> <li>Find the "container" of the image and then use the first block of text.</li> <li>Find the blocks of text in elements that contain certain classes ("description", "title") or elements (h1,h2,h3,h4).</li> </ul> <p>Title backups:</p> <ul> <li>Using Open Graph Tags</li> <li>Using just the <code>&lt;title&gt;</code></li> <li>Using ALT tags only</li> <li>Using META Tags</li> </ul> <p>Summary: Extracting the images isn't the problem, it's how to get relevant titles for them.</p> <p><strong>Question:</strong> How would you go about getting relevant titles for each of the images? Perhaps using DomDocument or XPath?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload