小白,网页循环
从谷歌爬取列表的时候总是提取一个内容一直循环。
属性表里 tr 的数据在变,这样改正确吗?
{“hasReachedRelativeAncestor”:“false”,“nodeHierarchyInfo”:[{“isPresentInSelector”:1,“otherAttributes”:{},“selectorInfo”:{“attributes”:{“aaname”:“一级 1 档”,“css-selector”:“#app > div:nth-child(1) > section:nth-child(3) > main:nth-child(2) > div:nth-child(2) > div:nth-child(3) > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(2) > section:nth-child(1) > main:nth-child(2) > section:nth-child(1) > main:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(2) > div:nth-child(2) > table:nth-child(3) > tbody:nth-child(2) > tr:nth-child({}) > td:nth-child(5) > div:nth-child(1) > span:nth-child(1)”,“parentid”:“app”,“tag”:“SPAN”,“xpath”:“//*[@id="app"]/div[1]/section[1]/main[1]/div[2]/div[1]/div[1]/div[1]/div[2]/div[1]/section[1]/main[1]/section[1]/main[1]/div[1]/div[1]/div[2]/div[2]/div[2]/table[1]/tbody[1]/tr[str(i)]/td[5]/div[1]/span[1]”},“index”:0,“tagName”:“SPAN”}}]}
你没对你做出修改的地方进行突出显示 看起来应该是 {} 那个地方,属性表的属性本质上是以字符串的方式传过去的, 用 f-string 语法可以实现动态修改 f‘{变量名称}’