- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我一直在 BS4 中构建一个网络抓取工具,但遇到了困难。我正在使用 Trip Advisor 作为我将要追踪的其他数据的测试,但无法隔离“整个”评论的标签。这是一个例子:
https://www.tripadvisor.com/Restaurant_Review-g56010-d470148-Reviews-Chez_Nous-Humble_Texas.html
注意,在第一次评论中,下面有一个图标“酒单是...”。我能够轻松隔离部分评论,但无法找到一种方法让 BS4 在模拟“更多”点击后提取评论。我想弄清楚这需要什么工具?我需要使用 Selenium 吗?
原始元素如下所示:
<span class="partnerRvw">
<span class="taLnk hvrIE6 tr475091998 moreLink ulBlueLinks" onclick=" ta.util.cookie.setPIDCookie(4444); ta.call('ta.servlet.Reviews.expandReviews', {type: 'dummy'}, ta.id('review_475091998'), 'review_475091998', '1', 4444);
">
More </span>
<span class="ui_icon caret-down"></span>
</span>
单击“更多”链接后查看 HTML,您会发现一个新的动态添加的类,其中包含我需要的信息(见下文):
<div class="review dyn_full_review inlineReviewUpdate provider0 first newFlag" style="display: block;">
<a name="UR475091998" class=""></a>
<div id="UR475091998" class="extended provider0 first newFlag">
<div class="col1of2">
<div class="member_info">
<div id="UID_6875524F623CC948F4F9CA95BB4A9567-SRC_475091998" class="memberOverlayLink" onmouseover="requireCallIfReady('members/memberOverlay', 'initMemberOverlay', event, this, this.id, 'Reviews', 'user_name_photo');" data-anchorwidth="90">
<div class="avatar profile_6875524F623CC948F4F9CA95BB4A9567 ">
<a onclick="">
<img src="https://media-cdn.tripadvisor.com/media/photo-l/0d/97/43/bf/joannecarpenter.jpg" class="avatar potentialFacebookAvatar avatarGUID:6875524F623CC948F4F9CA95BB4A9567" width="74" height="74">
</a>
</div>
<div class="username mo">
<span class="expand_inline scrname mbrName_6875524F623CC948F4F9CA95BB4A9567" onclick="ta.trackEventOnPage('Reviews', 'show_reviewer_info_window', 'user_name_name_click')">joannecarpenter</span>
</div>
</div>
<div class="location">
Humble, Texas
</div>
</div>
<div class="memberBadging g10n">
<div id="UID_6875524F623CC948F4F9CA95BB4A9567-CONT" class="no_cpu" onclick="ta.util.cookie.setPIDCookie('15984'); requireCallIfReady('members/memberOverlay', 'initMemberOverlay', event, this, this.id, 'Reviews', 'review_count');" data-anchorwidth="90">
<div class="levelBadge badge lvl_02">
Level <span><img src="https://static.tacdn.com/img2/badges/20px/lvl_02.png" alt="" class="icon" width="20" height="20/"></span> Contributor </div>
<div class="reviewerBadge badge">
<img src="https://static.tacdn.com/img2/badges/20px/rev_03.png" alt="" class="icon" width="20" height="20">
<span class="badgeText">6 reviews</span> </div>
<div class="contributionReviewBadge badge">
<img src="https://static.tacdn.com/img2/badges/20px/Foodie.png" alt="" class="icon" width="20" height="20">
<span class="badgeText">6 restaurant reviews</span>
</div>
</div>
</div>
</div>
<div class="col2of2">
<div class="innerBubble">
<div class="quote"><a href="/ShowUserReviews-g56010-d470148-r475091998-Chez_Nous-Humble_Texas.html#CHECK_RATES_CONT" onclick="ta.setEvtCookie('Reviews','title','',0,this.href); setPID();" id="r475091998">“<span class="noQuotes">Dinner</span>”</a></div>
<div class="rating reviewItemInline">
<span class="rate sprite-rating_s rating_s"> <img class="sprite-rating_s_fill rating_s_fill s50" width="70" src="https://static.tacdn.com/img2/x.gif" alt="5 of 5 bubbles">
</span>
<span class="ratingDate relativeDate" title="April 12, 2017">Reviewed 3 days ago
<span class="new redesigned">NEW</span> </span>
<a class="viaMobile" href="/apps" target="_blank" onclick="ta.util.cookie.setPIDCookie(24687)">
<span class="ui_icon mobile-phone"></span>
via mobile
</a>
</div>
<div class="entry">
<p>
Our favorite restaurant in Houston. Definitely the best and friendliest service! The food is not only served with a flair, it is absolutely delicious. My favorite is the Lamb. It is the best! Also the duck moose, fois gras, the crispy salad and the French onion soup are all spectacular! This is a must try restaurant! The wine list is fantastic. Just ask Daniel for suggestions. He not only knows his wines; he loves what he does! We Love this place!
</p>
</div>
<div class="rating-list">
<div class="recommend">
<span class="recommend-titleInline noRatings">Visited April 2017</span>
</div>
</div>
<div class="expanded lessLink">
<span class="taLnk collapse ulBlueLinks no_cpu ">
Less
</span>
<span class="textArrow_more ui_icon caret-up"></span>
</div>
<div id="helpfulq475091998_expanded" class="helpful redesigned white_btn_container ">
<span class="isHelpful">Helpful?</span> <div class="tgt_helpfulq475091998 rnd_white_thank_btn" onclick="ta.call('ta.servlet.Reviews.helpfulVoteHandlerOb', event, this, 'LeJIVqd4EVIpECri1GII2t6mbqgqguuuxizSxiniaqgeVtIJpEJCIQQoqnQQeVsSVuqHyo3KUKqHMdkKUdvqHxfqHfGVzCQQoqnQQZiptqH5paHcVQQoqnQQrVxEJtxiGIac6XoXmqoTpcdkoKAUAAv0tEn1dkoKAUAAv0zH1o3KUK0pSM13vkooXdqn3XmffAdvqndqnAfbAo77dbAo3k0npEEeJIV1K0EJIVqiJcpV1U0Ii9VC1rZlU3XozxbZZxE2crHN2TDUJiqnkiuzsVEOxdkXqi7TxXpUgyR2xXvOfROwaqILkrzz9MvzCxMva7xEkq8xXNq8ymxbAq8AzzrhhzCxbx2vdNvEn2fnwEfq8alzCeqi53ZrgnMrHhshTtowGpNSmq89IwiVb7crUJxdevaCnJEqI33qiE5JGErJExXKx5ooItGCy5wnCTx2VA7RvxEsO3'); ta.trackEventOnPage('HELPFUL_VOTE_TEST', 'helpfulvotegiven_v2');">
<img src="https://static.tacdn.com/img2/icons/icon_thumb_white.png" class="helpful_thumbs_up white">
<img src="https://static.tacdn.com/img2/icons/icon_thumb_green.png" class="helpful_thumbs_up green">
<span class="helpful_text">Thank joannecarpenter</span> </div>
</div>
<div class="tooltips vertically_centered">
<div class="reportProblem">
<span id="ReportIAP_475091998" class="problem collapsed taLnk" onclick="ta.trackEventOnPage('Report_IAP', 'Report_Button_Clicked', 'member'); ta.call('ta.servlet.Reviews.iapFlyout', event, this, '475091998')" onmouseover="if (!this.getAttribute('data-first')) {ta.trackEventOnPage('Reviews', 'report_problem', 'hover_over_flag'); this.setAttribute('data-first', 1)} uiOverlay(event, this)" data-tooltip="" data-position="above" data-content="Problem with this review?">
<img src="https://static.tacdn.com/img2/icons/gray_flag.png" width="13" height="14" alt="">
<span class="reportTxt">Report</span> </span>
</div>
</div>
<div class="userLinks">
<div class="sameGeoActivity">
<a href="/members-citypage/joannecarpenter/g56010" target="_blank" onclick="ta.setEvtCookie('Reviews','more_reviews_by_user','',0,this.href); ta.util.cookie.setPIDCookie(19160)">
See all 5 reviews by joannecarpenter for Humble </a>
</div>
<div class="askQuestion">
<span class="taLnk ulBlueLinks" onclick="ta.trackEventOnPage('answers_review','ask_user_intercept_click' ); ta.load('ta-answers', (function() {require('answers/misc').askReviewerIntercept(this, '470148', 'joannecarpenter', '6875524F623CC948F4F9CA95BB4A9567', 'en', '475091998','Chez Nous', 39151)}).bind(this), true);">Ask joannecarpenter about Chez Nous</span>
</div>
</div>
<div class="note">
This review is the subjective opinion of a TripAdvisor member and not of TripAdvisor LLC. </div>
<div class="duplicateReviewsInline">
<div class="previous">joannecarpenter has 1 more review of Chez Nous</div> <ul class="dupReviews">
<li class="dupReviewItem">
<div class="reviewTitle">
<a href="/ShowUserReviews-g56010-d470148-r453237869-Chez_Nous-Humble_Texas.html#REVIEWS">“Joanne Carpenter”</a>
</div>
<div class="rating">
<span class="rate sprite-rating_ss rating_ss"> <img class="sprite-rating_ss_fill rating_ss_fill ss50" width="50" src="https://static.tacdn.com/img2/x.gif" alt="5 of 5 bubbles">
</span>
<span class="date">Reviewed January 18, 2017</span>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="large">
</div>
<div class="ad iab_inlineBanner">
<div id="gpt-ad-468x60" class="adInner gptAd"></div>
</div>
</div>
BS4 有办法帮我处理这个问题吗?
最佳答案
这是一个帮助您入门的简单示例:
import selenium
from selenium import webdriver
driver = webdriver.PhantomJS()
url = "https://www.tripadvisor.com/Restaurant_Review-g56010-d470148-Reviews-Chez_Nous-Humble_Texas.html"
driver.get(url)
elem = driver.get_element_by_class_name("taLnk")
...
您可以在此处找到有关这些方法的更多信息: http://selenium-python.readthedocs.io/
关于python - Tripadvisor 抓取 'moreLink',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43423656/
我是 python3 网络抓取的新手。我想抓取迪拜所有酒店的评论,但问题是我只能抓取我在 url 中描述的酒店评论。谁能告诉我如何在不隐式提供每家酒店的网址的情况下获得所有酒店评论? import r
我的目标是在我的应用程序中与其他排名系统一起显示 TripAdvisor 评分排名。请记住,我的应用程序是 B2B 应用程序,而不是 B2C。 即使阅读了开发人员文档,我仍然无法理解的是我最终应该要求
我正面临网络抓取问题。我打算在 tripadvisor 上收集一些评论。我想使用 rvest 并获得所有语言的评论。来自 this questions我知道一种可能的方法是在 url 的末尾使用 ?f
我们目前正在开展一个 NLP 项目,需要一个旨在从 tripadvisor.com 中提取的语料库。我们期望输出有两种类型:评论和该评论的评级。我的问题是: 有没有最适合此目的的抓取工具?一定要简单易
我有一个场景,我需要单击tripadvisor内的气泡评级小部件的第五个气泡。 HTML 代码是: 我正在尝试使用以下代码片段: Actions action = new Actions(dri
在网站的页脚中,我想包含社交小部件。 Facebook 一个工作得很好,Tripadvisor 有很多行代码,而且没有真正的风格,跳出我的页脚等。 我最终如何为未设置样式的小部件设置样式?如果我更改代
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭1
我一直在 BS4 中构建一个网络抓取工具,但遇到了困难。我正在使用 Trip Advisor 作为我将要追踪的其他数据的测试,但无法隔离“整个”评论的标签。这是一个例子: https://www.tr
刚刚接受了 TripAdvisor 的电话面试(没有成功)。 我得到了下面的代码并要求我实现 findBestTravelAlert(用 Java)。 给定一个 TravelAlert 对象列表,找到
我想获取我正在使用 TripAdvisor API 的特定酒店的评分和评论。 我得到了这个链接: api.tripadvisor.com/api/partner/2.0/location/**8957
我想获取我正在使用 TripAdvisor API 的特定酒店的评分和评论。 我得到了这个链接: api.tripadvisor.com/api/partner/2.0/location/**8957
我正在尝试将 Tripadvisor 小部件 (rave) 添加到通过 Ajax 加载的页面。这是小部件代码: Read 37 reviews of Bond
我正在使用 Python-Scrapy 来删除 tripadvisor 成员(member)页面的评论。这是我正在使用的网址:http://www.tripadvisor.com/members/sc
在 TripAdvisor.com 景点页面上,景点网站的链接似乎以某种方式加密。这是一个例子: Website 这个链接是如何建立的,这样做的原因是什么? 最佳答案 aHref 值是一个
嗨,我是 angularjs 新手。我想向我的 angularjs 应用程序添加一个 tripadvisor 小部件。小部件代码如下:
我想知道如何从 Trip Advisor Api 获取特定地点的所有评论。现在我的电话是 http://api.tripadvisor.com/api/partner/2.0/location/SOM
我正在尝试抓取特定 TripAdivsor 页面的所有图像,但在 Selenium 中使用 find_elements_by_class_name 函数时,它没有给我任何值。我很困惑,因为这是我想要迭
我正在尝试将 Tripadvisor 评分小部件添加到我的 React 网站(请参阅下面的代码)。目前,只有 Tripadvisor 日志正在加载,没有评级信息。我认为小部件中的脚本没有运行,我不确定
本周,我开始为一位经营旅游公司的家庭成员开发我的第一个 WordPress 网站,该成员有一个非常过时的网站,我决定从头开始构建该网站。 一切都很顺利,直到我决定将他的一些 TripAdvisor 小
来自 this页面,我想抓取列表“迈阿密的事件类型”(您可以在页面末尾附近找到它)。这是我到目前为止所拥有的: import requests from bs4 import BeautifulSou
我是一名优秀的程序员,十分优秀!