【发布时间】:2022-12-02 19:06:34
【问题描述】:
My app allows users to build webscrapers without code. We want to allow an event called \'get all\' that gets every iteration of that same path in the list.
On this website https://www.worldometers.info/geography/alphabetical-list-of-countries/
Afghanistan would be
/html/body/div[3]/div[2]/div[1]/div/div[2]/table/tbody/tr[1]/td[2]
Albania
/html/body/div[3]/div[2]/div[1]/div/div[2]/table/tbody/tr[2]/td[2]
If I want to query for all, I can manually edit the xpath to be (remove index from last tr)
/html/body/div[3]/div[2]/div[1]/div/div[2]/table/tbody/tr/td[2]
the issue is this same structure (using tables) wont be repeated on every site I.e. google page result, instagram user list, etc.
With puppeteer what would be my best method to find \'similar\' items on the page?
标签: web-scraping xpath puppeteer
table trbut it\'s still not a silver bullet. What do you mean by \'similar\' items exactly?