【发布时间】:2017-09-08 04:08:10
【问题描述】:
我正在尝试从 “我在很小的时候就理解...宇宙的精神。” 和作者的名字 “Alice Walker” 从以下 Javascript 代码:
<div id="qpos_4_3" class="m-brick grid-item boxy bqQt" style="position: absolute; left: 0px; top: 33815px;">
<div class="">
<a href="/quotes/quotes/a/alicewalke625815.html?src=t_age" class="b-qt
qt_625815 oncl_q" title="view quote">I understood at a very early age that
in nature, I felt everything I should feel in church but never did.
Walking in the woods, I felt in touch with the universe and with the
spirit of the universe.
</a>
<a href="/quotes/authors/a/alice_walker.html" class="bq-aut qa_625815
oncl_a" title="view author">Alice Walker</a>
</div>
<div class="kw-box">
<a href="/quotes/topics/topic_nature.html" class="oncl_k" data-
idx="0">Nature</a>,
</div>
我使用了 chrome 的开发者工具栏来获取 xpath。以下代码旨在提取报价,但它输出character(0)。我做错了什么?
link <- "https://www.brainyquote.com/quotes/topics/topic_age.html"
quote <- read_html(link)
quote %>%
html_nodes(xpath = '//*[@id="qpos_4_3"]/div[1]/a[1]') %>%
html_attr('view quote')
【问题讨论】:
-
“您不得通过使用机器人、蜘蛛、爬虫、网络爬虫、索引代理或其他自动化设备访问、使用或复制本网站的任何部分或其内容,或机制。您同意不删除或修改任何版权声明或商标图例、作者署名或放置或包含在任何网站内容中的其他声明。除非我们以书面形式明确授权,否则您在任何情况下都不会复制、重新分发、复制、复制、修改、分发……” 最佳阅读项目 5 here。
-
仅供个人使用和练习创建机器人,但感谢您指出这一点。我会非常小心的。
标签: javascript r xpath web-scraping