该tidy
宝石不再维护,并有多个内存泄漏问题.
有人建议使用Nokogiri.
我目前正在使用以下方法清理HTML:
Nokogiri::HTML::DocumentFragment.parse(html).to_html
我有两个问题:
Nokogiri删除了 DOCTYPE
有没有一种简单的方法可以强制清理的HTML有一个html
和body
标签?
我正在寻找屏幕抓取和控制OS X中的鼠标为一个业余爱好项目.
我不是在寻找最优雅的方式,但我需要能够每半秒左右捕获一次屏幕.
我发现我可以使用screencapture
命令行工具(screencapture -w -W -i ~/Desktop/capture.jpg
),但我担心它可能不够快.
我也在寻找一种发送点击,设置光标位置和获取光标位置的方法.有点像什么WIN32API提供:mouse_event
,SetCursorPos
和GetCursorPos
.
我发现这个示例代码使用PyObjC库设置光标位置,但它总是将鼠标移动到(0,0)而不是我传递它的坐标.
import objc
class ETMouse():
def setMousePosition(self, x, y):
bndl = objc.loadBundle('CoreGraphics', globals(),
'/System/Library/Frameworks/ApplicationServices.framework')
objc.loadBundleFunctions(bndl, globals(),
[('CGWarpMouseCursorPosition', 'v{CGPoint=ff}')])
CGWarpMouseCursorPosition((x, y))
if __name__ == "__main__":
et = ETMouse()
et.setMousePosition(500, 500)
Run Code Online (Sandbox Code Playgroud)
编辑:如果重要的话,我正在运行Snow Leopard(10.6).
谢谢!