深圳宝安网站设计公司,海口网站建设找千素网,推广线上渠道,网站悬浮广告素材我试图从以下链接中获取以下svg#xff1a;我要刮的部分如下#xff1a;我不需要图表中的文字(只需要图表本身)。但是#xff0c;我以前从来没有抓取过svg图像#xff0c;我不确定这是否可能。我环顾四周#xff0c;但找不到任何有用的python包来直接执行此操作。在我知道…我试图从以下链接中获取以下svg我要刮的部分如下我不需要图表中的文字(只需要图表本身)。但是我以前从来没有抓取过svg图像我不确定这是否可能。我环顾四周但找不到任何有用的python包来直接执行此操作。在我知道我可以用python使用selenium截图图像然后使用PIL裁剪它并将其保存为svg但我想知道是否有更直接的方法从页面上获取这些图表。任何有用的包或实现都会很有帮助。谢谢您。在编辑得到了一些反对票但不确定为什么我会以我的方式来实施它。。在import sysimport timefrom PyQt4.QtCore import *from PyQt4.QtGui import *from PyQt4.QtWebKit import *class Screenshot(QWebView):def __init__(self):self.app QApplication(sys.argv)QWebView.__init__(self)self._loaded Falseself.loadFinished.connect(self._loadFinished)def capture(self, url, output_file):self.load(QUrl(url))self.wait_load()# set to webpage sizeframe self.page().mainFrame()self.page().setViewportSize(frame.contentsSize())# render imageimage QImage(self.page().viewportSize(), QImage.Format_ARGB32)painter QPainter(image)frame.render(painter)painter.end()print saving, output_fileimage.save(output_file)def wait_load(self, delay0):# process app events until page loadedwhile not self._loaded:self.app.processEvents()time.sleep(delay)self._loaded Falsedef _loadFinished(self, result):self._loaded Trues Screenshot()s.capture(https://finance.yahoo.com/quote/AAPL/analysts?pAAPL, yhf.png)然后我将使用PIL中的crop函数将图像从图表中取出。在