初用selenium爬取京东商品评论,无法找到想要的数据
driver = webdriver.Chrome(chromepath)driver.get("https://item.jd.com/4161503.html")
comment = driver.find_element_by_css_selector('div.reply-content')
content = eachcomment.find_element_by_tag_name('p')
print(content.text)
以上是源码
报错是:NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"div.comment-column.J-comment-column"}
(Session info: chrome=57.0.2987.133)
(Driver info: chromedriver=2.29.461591 (62ebf098771772160f391d75e589dc567915b233),platform=Windows NT 6.1.7601 SP1 x86_64)
对网页检查
<div id="comment-0" data-tab="item">........</div>这对标签内有内容
但运行driver.page_source时
看到<div id="comment-0" data-tab="item">全部评论</div>n
回答:
把page参数改改就可以拿全部评论,代表页数
https://sclub.jd.com/comment/...
以上是 初用selenium爬取京东商品评论,无法找到想要的数据 的全部内容, 来源链接: utcz.com/a/162987.html