python이나 php에 기존 템플릿 추출 라이브러리가 있습니까? Perl은 Template::Extract이지만 파이썬이나 PHP에서 비슷한 구현을 찾을 수 없었습니다.python/php의 템플릿 추출
내가 찾을 수있는 파이썬에서 가까운 유일한 것은 TemplateMaker (http://code.google.com/p/templatemaker/)이지만 실제로는 템플릿 추출 라이브러리가 아닙니다.
python이나 php에 기존 템플릿 추출 라이브러리가 있습니까? Perl은 Template::Extract이지만 파이썬이나 PHP에서 비슷한 구현을 찾을 수 없었습니다.python/php의 템플릿 추출
내가 찾을 수있는 파이썬에서 가까운 유일한 것은 TemplateMaker (http://code.google.com/p/templatemaker/)이지만 실제로는 템플릿 추출 라이브러리가 아닙니다.
좀 더 파고 들어서 내가 찾고있는 솔루션을 발견했습니다. filippo는이 게시물의 스크린 스크 레이 핑을위한 파이썬 솔루션리스트를 올렸습니다 : Options for HTML scraping? 그중 scrapemark (http://arshaw.com/scrapemark/) 패키지가 있습니다.
희망은 동일한 솔루션을 찾는 다른 사용자에게 도움이되기를 바랍니다.
TmeplateMaker
적어도 설명서에 따르면 필요한 것을 수행하는 것 같습니다. 템플릿을 입력으로받는 대신 몇 개의 문서에서 템플릿을 유추 ("습득")합니다. 그런 다음이 템플릿으로 만든 다른 문서에서 데이터를 추출하는 방법은 extract
입니다.
의 예를 보여줍니다
# Now that we have a template, let's extract some data.
>>> t.extract('<b>red and green</b>')
('red', 'green')
>>> t.extract('<b>django and stephane</b>')
('django', 'stephane')
# The extract() method is very literal. It doesn't magically trim
# whitespace, nor does it have any knowledge of markup languages such as
# HTML.
>>> t.extract('<b> spacy and <u>underlined</u></b>')
(' spacy ', '<u>underlined</u>')
# The extract() method will raise the NoMatch exception if the data
# doesn't match the template. In this example, the data doesn't have the
# leading and trailing "<b>" tags.
>>> t.extract('this and that')
Traceback (most recent call last):
...
을 그래서, 당신이 필요로하는 작업을 달성하기 위해, 당신이해야한다고 생각 :
은 당신이 그것을 깨끗한 템플릿을 제공하기 위해 기대하지 않는 것이 훨씬 더 유용 펄의 Template::Extract
이상입니다, 그것에 대해 생각해 보면 - 그것은 샘플 텍스트에서 그 자체를 배운다.
여기 아드리안에서 흥미로운 토론 내가 래퍼 유도 라이브러리라고 부르는 같은 많은 것 같다 TemplateMaker http://www.holovaty.com/writing/templatemaker/
의 저자이다.
더 많은 것을 구성 할 수있는 (스크래핑을 줄이기 위해) 뭔가 다른 것을 찾으려면 lxml.html과 BeautifulSoup, 또한 Python을 살펴보십시오.
@ 카일 : 어쩌면 당신의 질문에 대해 다시 말해야합니다. –