웹 캡처 및 변환 도구

URL과 HTML을 DOCX로 변환

파이썬 API

HTML 또는 웹 페이지를 변환하는 기능 추가 into 응용 프로그램에 대한 Word 문서가 더 쉬워졌습니다. GrabzIt은 Python API입니다. 그러나 시작하기 전에 URLToDOCX, HTMLToDOCX or FileToDOCX 방법 Save or SaveTo 실제로 DOCX를 작성하려면 메소드를 호출해야합니다.

기본 옵션

웹 페이지를 DOCX로 캡처하면 전체 웹 페이지가 변환됩니다 into 여러 페이지로 구성 될 수있는 Word 문서. 웹 페이지를 변환하려면 하나의 매개 변수 만 필요합니다 intoa Word 문서 또는 HTML을 DOCX로 변환 아래 예제와 같이.

grabzIt.URLToDOCX("https://www.tesla.com")
# Then call the Save or SaveTo method
grabzIt.HTMLToDOCX("<html><body><h1>Hello World!</h1></body></html>")
# Then call the Save or SaveTo method
grabzIt.FileToDOCX("example.html")
# Then call the Save or SaveTo method

맞춤식 식별자

사용자 지정 식별자를 DOCX 아래 표시된대로 메소드를 사용하면이 값이 GrabzIt Python 핸들러로 리턴됩니다. 예를 들어이 사용자 지정 식별자는 데이터베이스 식별자 일 수 있으며 DOCX 문서를 특정 데이터베이스 레코드와 연결할 수 있습니다.

from GrabzIt import GrabzItDOCXOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItDOCXOptions.GrabzItDOCXOptions()
options.customId = "123456"

grabzIt.URLToDOCX("https://www.tesla.com", options)
# Then call the Save method
grabzIt.Save("http://www.example.com/handler.py")
from GrabzIt import GrabzItDOCXOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItDOCXOptions.GrabzItDOCXOptions()
options.customId = "123456"

grabzIt.HTMLToDOCX("<html><body><h1>Hello World!</h1></body></html>", options)
# Then call the Save method
grabzIt.Save("http://www.example.com/handler.py")
from GrabzIt import GrabzItDOCXOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItDOCXOptions.GrabzItDOCXOptions()
options.customId = "123456"

grabzIt.FileToDOCX("example.html", options)
# Then call the Save method
grabzIt.Save("http://www.example.com/handler.py")

머리글과 바닥 글

Word 문서에 머리글이나 바닥 글을 추가하려면 특정 머리글이나 바닥 글을 적용하도록 요청할 수 있습니다 이 템플릿 생성되는 DOCX에. 이 템플릿은 saved를 미리 지정하고 특수 변수와 함께 머리글과 바닥 글의 내용을 지정합니다. 아래 예제 코드에서 사용자는 "my template"이라는 템플릿을 사용하고 있습니다.

from GrabzIt import GrabzItDOCXOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItDOCXOptions.GrabzItDOCXOptions()
options.templateId = "my template"

grabzIt.URLToDOCX("https://www.tesla.com", options)
# Then call the Save or SaveTo method
grabzIt.SaveTo("result.docx")
from GrabzIt import GrabzItDOCXOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItDOCXOptions.GrabzItDOCXOptions()
options.templateId = "my template"

grabzIt.HTMLToDOCX("<html><body><h1>Hello World!</h1></body></html>", options)
# Then call the Save or SaveTo method
grabzIt.SaveTo("result.docx")
from GrabzIt import GrabzItDOCXOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItDOCXOptions.GrabzItDOCXOptions()
options.templateId = "my template"

grabzIt.FileToDOCX("example.html", options)
# Then call the Save or SaveTo method
grabzIt.SaveTo("result.docx")

HTML 요소를 DOCX로 변환

div 또는 span과 같은 HTML 요소를 직접 변환하려는 경우 into GrabzIt의 Python 라이브러리로 Word 문서를 작성할 수 있습니다. 당신은 통과해야합니다 CSS 선택기 로 변환하려는 HTML 요소의 targetElement GrabzIt의 방법DOCXOptions 클래스입니다.

...
<span id="Article">
<p>This is the content I am interested in.</p>
<img src="myimage.jpg">
</span>
...

이 예에서는 ID가 Article따라서 아래와 같이 GrabzIt API에 전달합니다.

from GrabzIt import GrabzItDOCXOptions
from GrabzIt import GrabzItClient

grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzItDOCXOptions.GrabzItDOCXOptions()
options.targetElement = "#Article"

grabzIt.URLToDOCX("http://www.bbc.co.uk/news", options)
# Then call the Save or SaveTo method
grabzIt.SaveTo("result.docx")