如何导出scruyt提取器?

发布于 2024-09-03 13:57:38 字数 321 浏览 9 评论 0原文

我编写了一个基于“学习”技术的 scrapyt 提取器,即指定页面上的当前文本并让它计算出 XPath 表达式本身。但是,我现在想导出提取器,以便即使页面发生更改也可以使用它。

scrapyt 的文档现在似乎到处都是,但从我能找到的内容来看,我应该能够放置该行 extractor.export(__FILE__) 并且它应该可以工作。它没有 - 我只是收到一个错误,说导出的参数数量错误,它应该有 0。我已经在没有任何参数的情况下尝试过,但它仍然失败。

我会在 scrapyt 论坛上询问,但似乎已经很久没有人去过那里了!

有什么想法在这里做什么吗?

I've written a scrubyt extractor based on the 'learning' technique - that is, specifying the current text on the page and getting it to work out the XPath expressions itself. However, I now want to export the extractor so that it can be used even when the page has changed.

The documentation for scrubyt seems to be all over the place now, but from what I can find I should be able to put the line extractor.export(__FILE__) and it should work. It doesn't - I just get an error saying that there is the wrong number of arguments for export, it should have 0. I've tried it without any arguments and it still fails.

I would ask on the scrubyt forum, but it seems like no-one's been there for ages!

Any ideas what to do here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

多彩岁月 2024-09-10 13:57:38

刚刚遇到了同样的问题并尝试了“puts google_data.export()”(试图从谷歌获取一些东西)

这给了我以下内容:

===提取树===

 export() 目前不起作用,因为删除或

ParseTree、ruby2ruby 和 RubyInline。
现在,如果您使用示例,您可以手动替换它们
基于下面的输出。
因此,如果学习提取器中的模式看起来像

 书“Ruby Cookbook” 

 您会看到以下内容:

 [书]/表[1]/tr/td[2]

 然后将“Ruby Cookbook”替换为“/table[1]/tr/td[2]”(以及所有

其他 XPath),您就准备好了!
[链接] /body/div/div/div/div/div/ol/li/h3/a

这给了我我正在寻找的 xpath

scrapyt 版本是 0.4.06

Just had the same problem and tried "puts google_data.export()" (trying to get some stuff from google)

This gave me the following:

=== Extractor tree ===

 export() is not working at the moment, due to the removal or

ParseTree, ruby2ruby and RubyInline.
For now, in case you are using examples, you can replace them by hand
based on the output below.
So if your pattern in the learning extractor looks like

 book "Ruby Cookbook" 

 and you see the following below:

 [book] /table[1]/tr/td[2]

 then replace "Ruby Cookbook" with "/table[1]/tr/td[2]" (and all the

other XPaths) and you are ready!
[link] /body/div/div/div/div/div/ol/li/h3/a

which gave me the xpath I was looking for

scrubyt version is 0.4.06

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文