提问人:EliudM 提问时间:5/27/2018 最后编辑:EliudM 更新时间:7/16/2019 访问量:1270
Solr post.jar 崩溃并显示“prolog 中不允许内容”
Solr post.jar crashes with "content is not allowed in prolog"
问:
我正在尝试评估 Solr,但无法开始抓取带有递归选项的网站。到处寻找答案,但没有运气。 环境:Windows Server 2012 r2,java 版本“1.8.0_171”,solr-7.3.0。
运行post.jar工具时,出现以下错误:
java -Dauto=yes -Dc=testcore -Ddata=web -Drecursive=2 -Ddelay=10 -jar post.jar http://localhost/
SimplePostTool version 5.0.0
Posting web pages to Solr url http://localhost:8983/solr/testcore/update/extract
Entering auto mode. Indexing pages with content-types corresponding to file endings xml,json,jsonl,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt,log
Entering recursive mode, depth=2, delay=10s
Entering crawl at level 0 (1 links total, 1 new)
POSTed web resource http://localhost/ (depth: 0)
[Fatal Error] :1:1: Content is not allowed in prolog.
Exception in thread "main" java.lang.RuntimeException: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
at org.apache.solr.util.SimplePostTool$PageFetcher.getLinksFromWebPage(SimplePostTool.java:1252)
at org.apache.solr.util.SimplePostTool.webCrawl(SimplePostTool.java:616)
at org.apache.solr.util.SimplePostTool.postWebPages(SimplePostTool.java:563)
at org.apache.solr.util.SimplePostTool.doWebMode(SimplePostTool.java:365)
at org.apache.solr.util.SimplePostTool.execute(SimplePostTool.java:187)
at org.apache.solr.util.SimplePostTool.main(SimplePostTool.java:172)
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at org.apache.solr.util.SimplePostTool.makeDom(SimplePostTool.java:1061)
at org.apache.solr.util.SimplePostTool$PageFetcher.getLinksFromWebPage(SimplePostTool.java:1232)
... 5 more
如果我在关闭递归选项的情况下逐个索引,我可以手动索引 http://localhost/ 中的所有链接(指向文件和其他页面),因此我认为没有任何带有特殊字符的文件或链接。谢谢大家,感谢您的帮助。
答:
我无法让 post.jar 工具正常工作。在尝试并排除了 Nutch 1.8 的故障后,我终于能够让它抓取网页并自动跟踪链接。 这就是我所做的:安装cygwin,将Nutch安装/解压到cygwin/home文件夹,下载Hadoop-0.20.20-core.jar并粘贴到cygwin/home/apache-nutch-1.8/lib。 完成此操作后,我能够在此处完成 Nutch 教程: https://wiki.apache.org/nutch/NutchTutorial 在此过程中还有其他一些小问题,但我真的不记得那些是什么(我需要处理更好的文档......),无论如何,如果有人在与我的类似环境中尝试这样做,请随时给我发消息。
删除 -Drecursive=2 ,它正在使用以下命令创建问题。
java -Dauto=yes -dc=testcore -ddata=web -ddelay=10 -jar post.jar http://localhost/
评论
使用 Drupal,我用一个 6 行 shell 脚本解决了这个问题,不需要 nutch 等,以及这需要的研发、环境问题等:
#!/bin/bash
x=0
while [ "$x" != "37142" ]
do
/opt/solr/bin/post -c drupal_dev https://www.[yoursite].com/node/$x
let "x+=1"
done
您可以使用 drush 动态生成最高节点号。
您可以轻松地将其调整为使用wget生成的URL列表来抓取您的网站,或者只是将它们发布为wget抓取您的网站。如果我从营销部门那里得到关于使用 /node/[nodeId] url 的反对,我计划这样做。
这个特殊的 shell 脚本足够慢,我什至不需要延迟。
评论