TableGeneration
TableGeneration copied to clipboard
Tips: Mac上使用该工具,框坐标需要乘以2
在用MacBook用该工具时,发现最终裁剪的表格总是原始表格部分内容,不完整。
参考python使用selenium截屏后再截取指定坐标图片定位不准确是为什么 回答,解决了问题。
更改以下位置代码 https://github.com/WenmuZhou/TableGeneration/blob/d94348379d2131cf0d72bcd915643fe2691b2d7c/TableGeneration/GenerateTable.py#L207-L227
为以下:
ratio = 2
max_height, max_width = window_size["height"], window_size["width"]
max_height *= ratio
max_width *= ratio
contens = []
for idx in range(id_count):
e = WebDriverWait(self.driver, 3).until(
EC.presence_of_element_located((By.ID, str(idx)))
)
txt = e.text.strip()
lentext = len(txt)
loc = e.location
size_ = e.size
xmin = loc["x"]
ymin = loc["y"]
xmax = int(size_["width"] + xmin)
ymax = int(size_["height"] + ymin)
xmin *= ratio
ymin *= ratio
xmax *= ratio
ymax *= ratio
contens.append(
[lentext, txt, [[xmin, ymin], [xmax, ymin], [xmax, ymax], [xmin, ymax]]]
)
欢迎提个pr
没问题,我整理一下。
之前也一直想写这个工具来着,后来发现您先做了。巧了不是。