使用RSelenium将值拉出页面来源

问题描述 投票:0回答:1

全部。我对HTML / CSS / XML / etc并不敏锐。我正在尝试使用RSelenium浏览到我正在观看的Camper Trailer的链接。我正在寻找最新价格。我想拿回它。

我了解RSelenium中的过程,但是,我很难找到与价格相关的元素。

拖车的价格在几个地区存在,但这是最清晰的标签。我将如何使用RSelenium从该来源解析15000的值?价格在下面的代码块末尾。

谢谢!

源链接:https://www.rvtrader.com/listing/2012-Jayco-JAY-FLIGHT-29QBH-5010528237

<script async="async">window.lpTag=window.lpTag||{},void 0===window.lpTag._tagCount?(window.lpTag={site:"p-744",env:"us",providerId:"744",section:lpTag.section||"",autoStart:!1!==lpTag.autoStart,ovr:lpTag.ovr||{domain:"tag.contactatonce.com",tagjs:""},_v:"1.0",_tagCount:1,protocol:"https:",events:{bind:function(t,e,i){lpTag.defer(function(){lpTag.events.bind(t,e,i)},0)},trigger:function(t,e,i){lpTag.defer(function(){lpTag.events.trigger(t,e,i)},1)}},defer:function(t,e){0==e?(this._defB=this._defB||[],this._defB.push(t)):1==e?(this._defT=this._defT||[],this._defT.push(t)):(this._defL=this._defL||[],this._defL.push(t))},sdk:{exec:function(t,e){lpTag._defExec=lpTag._defExec||{},lpTag._defExec[t]=lpTag._defExec[t]||[],lpTag._defExec[t].push(e)}},load:function(t,e,i){var n=this;setTimeout(function(){n._load(t,e,i)},0)},_load:function(t,e,i){var n=t;t||(n=this.protocol+"//"+(this.ovr&&this.ovr.domain?this.ovr.domain:"tag.contactatonce.com")+"/tag/tag.js");var a=document.createElement("script");a.setAttribute("charset",e||"UTF-8"),i&&a.setAttribute("id",i),a.setAttribute("src",n),document.getElementsByTagName("head").item(0).appendChild(a)},init:function(){this._timing=this._timing||{},this._timing.start=(new Date).getTime();var t=this;window.attachEvent?window.attachEvent("onload",function(){t._domReady("domReady")}):(window.addEventListener("DOMContentLoaded",function(){t._domReady("contReady")},!1),window.addEventListener("load",function(){t._domReady("domReady")},!1)),void 0===window._caotStop&&this.load()},start:function(){this.autoStart=!0},_domReady:function(t){this.isDom||(this.isDom=!0,this.events.trigger("CAOT","DOM_READY",{t:t})),this._timing[t]=(new Date).getTime()},vars:lpTag.vars||[],dbs:lpTag.dbs||[],ctn:lpTag.ctn||[],sdes:lpTag.sdes||[],ev:lpTag.ev||[],tagletCommands:lpTag.tagletCommands||[]},lpTag.init()):window.lpTag._tagCount+=1;</script> <script>window.adpearance = {"pageInfo":{"isVdp":1,"inventoryItem":{"dealerId":"","adId":"5010528237","condition":"U","year":2012,"make":"Jayco","model":"JAY FLIGHT 29QBH","category":"","class":"Travel Trailer","price":"$15,000","city":"Atwater","state":"CA"}}};</script>
r web-scraping rselenium
1个回答
0
投票

种类繁多,但不是尝试理解/解析所有源代码,而是使用下面的代码来获取所有源代码并搜索模式。这对我有用。

source <- driver$client$getPageSource()
match <- stri_match_first_regex(source, "trk.prodprice.+?';|Sorry, this listing has been removed")
© www.soinside.com 2019 - 2024. All rights reserved.