How is one able to get the xpath from x/y coordinates?

  • Hello Qt gurus.., I have an interesting problem I am trying to solve and believe QtWebKit might be just the solution I am looking for but I am not 100% sure.

    In short, I am essentially trying to screen scrape some data from a site. The location of this data does not follow a specific structure thus not allowing me to define the content by referencing an ID or element class. It also does not allow for any standard means of defining the data via regular expressions.

    The only uniform pattern which exists is that the content piece I am trying to define is the largest piece of content on each page.

    Initially I was thinking there must be some simple way to define the largest visible content block within a page but it seems this is not possible (anyone?)... even more interesting would be a solution which could somehow output the largest inside width/height block of a page.

    In any case, what lead me to think about WebKit was the coordinate system as it seems that the content block I am interested in always starts in relatively the same location.

    So, if no simpler solution exists then I would be interested to know what solution may exist which would allow me to pass an X/Y coordinate to WebKit and have it return to me the xpath of the element at that position.

    My hack workaround would be to pass around 9 X/Y coordinates after a page is rendered and get the associating xpath for the element at that position.... I would then run an extract from the closest xpath element containing content and compare the results with the effect of defining the largest content block.

    Anyone able to share some insight into how this could be preformed or provide an alternative solution to the problem I am trying to solve?

    Thanks in advance!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.