2012-05-27 1 views
1

웹 수확 api를 사용하는 모바일 앱을 제작하여 웹 사이트에서 데이터를 추출하고 파일에 저장합니다. 그런 다음 앱은 데이터를 조작하여 표시합니다. 내 문제는 Java 용 webharvest를 사용할 때 config 파일과 출력 파일의 경로가 "C : /config.xml"및 "C :/docs"와 같은 로컬 디스크와 관련이 있지만 Android 프로젝트에서 설정 파일이 프로젝트에 있어야하고 출력 파일이 프로젝트 또는 캐시에 있어야합니다. 웹 수확물 설정을 읽는 경로와 출력 XML 파일을 작성하는 경로를 누구에게 말해 줄 수 있습니까?Android에서 웹 수확 사용

답변

0

나는 같은 문제가 있으며, 슬프게도 나는 그것을 작동시킬 수 없다. 다음 해결책에 대해 생각했지만 예외가 throw됩니다.

InputStream in_s = context.getResources().openRawResource(R.raw.webharvestconfig); 
InputSource inputSource = new InputSource(in_s); 
ScraperConfiguration config = new ScraperConfiguration(inputSource); 

예외 :

04-25 16:47:26.835: W/System.err(1057): org.webharvest.exception.ParserException: asset 
04-25 16:47:26.835: W/System.err(1057): at org.webharvest.definition.XmlParser.parse(Unknown Source) 
04-25 16:47:26.846: W/System.err(1057): at org.webharvest.definition.XmlNode.getInstance(Unknown Source) 
04-25 16:47:26.846: W/System.err(1057): at org.webharvest.definition.ScraperConfiguration.createFromInputStream(Unknown Source) 
04-25 16:47:26.846: W/System.err(1057): at org.webharvest.definition.ScraperConfiguration.<init>(Unknown Source) 

나는이 같은 직접의 InputStream에 XML 문자열을 작성하는 시도 :

InputStream in = new ByteArrayInputStream("<?xml version=\"1.0\" encoding=\"UTF-8\"?><config charset=\"UTF-8\"><html-to-xml> <http url=\"http://www.google.com\"/> </html-to-xml></config>".getBytes()); 

그러나 더 나은 운이없는 (예외가 달랐다 있지만).

이론상으로는 잘 작동하지 않습니다. 난 그냥 보여 예외 연구하는 동안 , 나는 심지어 같은 내가 할 방법하지만를 ScraperConfiguration를 사용하는 following example ...

그냥 완전성의 흔들림에 대한 더 많은 정보를 제공하는

, 내가 source code에서 제공 발견 ScrapeConfiguration 클래스

작동하도록 만들 수 있다면이 게시물을 편집 할 것입니다.