Извлечение значения из источника с помощью RSelenium - PullRequest
0 голосов
/ 23 апреля 2020

Все. Я не супер проницателен в HTML / CSS / XML / et c. Я пытаюсь использовать 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>

1 Ответ

0 голосов
/ 23 апреля 2020

В некотором роде обманщики, но вместо того, чтобы пытаться понять / разобрать весь этот исходный код, я просто использовал приведенный ниже код, чтобы получить весь исходный код и найти шаблон. Это сработало для меня.

source <- driver$client$getPageSource()
match <- stri_match_first_regex(source, "trk.prodprice.+?';|Sorry, this listing has been removed")
...