Thanks for the details. The iMacros “Relative positioning” is a clever method. And it was really good when iMacros was invented. But meanwhile XPath can be used to do almost the same. (If you find an example or use case that can not be done with XPath, please let me know!)
If i need to save all uptime of Los Angeles what solution i can use with ui vision?
You almost had the solution You can use the XPath CONTAINS selector to search for a parent element with a given text (as you did) and then use /td[X] to select the table column that you need. So for the first column (here to extract the IP address) it is /td[1]. This screenshot shows what I mean:
We use XPath Contains to search for the row that has the word “US” and then scrape the other cells in this row, e. g. the IP address:
My test macro is below. In it I use click
for quicker testing. To actually extract the value just replace it with the storeText
web scraping command.
{
"Name": "xpathcontains",
"CreationDate": "2020-6-1",
"Commands": [
{
"Command": "open",
"Target": "https://free-proxy-list.net/",
"Value": ""
},
{
"Command": "comment",
"Target": "Locator as recorded",
"Value": ""
},
{
"Command": "click",
"Target": "xpath=//*[@id=\"proxylisttable\"]/tbody/tr[1]/td[1]",
"Value": ""
},
{
"Command": "click",
"Target": "xpath=//*[@id=\"proxylisttable\"]/tbody/tr[2]/td[3]",
"Value": ""
},
{
"Command": "click",
"Target": "xpath=//*[@id=\"proxylisttable\"]/tbody/tr[1]/td[3]",
"Value": ""
},
{
"Command": "click",
"Target": "xpath=//*[@id=\"proxylisttable\"]/tbody/tr[2]/td[1]",
"Value": ""
},
{
"Command": "comment",
"Target": "New locator with CONTAINS",
"Value": ""
},
{
"Command": "click",
"Target": "xpath=//*[contains(.,\"US\")][1]/td[1]",
"Value": ""
},
{
"Command": "click",
"Target": "xpath=//*[contains(.,\"US\")][1]/td[3]",
"Value": ""
},
{
"Command": "click",
"Target": "xpath=//*[contains(.,\"US\")][2]/td[1]",
"Value": ""
},
{
"Command": "click",
"Target": "xpath=//*[contains(.,\"US\")][2]/td[3]",
"Value": ""
}
]
}
PS: I also tested with http://www.freeproxylists.net/
from your example and (only) there I have the very strange problem can I can never select the first match for a given Xpath contains. Very strange. But on all other tables that I tested the above XPath contains locator strategy works well.