2017-09-26 10 views
0

rvest pkgを使用してウェブをスクラップするWebを初めて使用しているので、誰でもこのhtmlスクリプトを手伝ってください。私は障害物を簡単に描写するためにhtmlファイルを投稿します。私が望むのは、 <li ng-if="check_int(profile.funding_round.investment_total)" class= "ng-binding ng-scope">の下の合計値ですが、brタグの直前の値です。 htmlの挿入の最後の行を見てください。どうもありがとうございます。Angular JSディレクティブでRを使用したWebスクラブ

<ul class="page-highlights no-bullet-list inline-list tight-list ng-scope" ng-if="profile.investability.action == 'invest' || profile.investability.action == 'show_oversubscribed_warning' || profile.investability.action == 'quiz_and_invest' || !profile.investability.action || profile.investability.reason == 'anonymous' || profile.offering_type.is_regcf || profile.investability.action == 'show_investment_summary' || profile.investability.action == 'invest_interest' || profile.investability.action == 'reserve' || profile.investability.action == 'show_reservation_summary' || profile.investability.action == 'submit_reservation' || profile.investability.action == 'confirm_investment'"> 
 
    <!-- ngIf: check_int(profile.funding_round.investment_total) --><li ng-if="check_int(profile.funding_round.investment_total)" class="ng-binding ng-scope">$704,145<br><span class="label">Amount raised</span></li><!-- end ngIf: check_int(profile.funding_round.investment_total) --> 
 

 
    <!-- ngIf: check_int(profile.funding_round.investment_count) > 500 --> 
 

 
    <!-- ngIf: check_int(profile.funding_round.reservation_total) --> 
 

 
    <!-- ngIf: profile.funding_round.min_investment_per_investor && !profile.offering_type.is_rega_plus --> 
 

 
    <!-- ngIf: profile.share_price && profile.offering_type.is_rega_plus --><li ng-if="profile.share_price &amp;&amp; profile.offering_type.is_rega_plus" class="ng-binding ng-scope"> 
 
    $0.50 <br><span class="label">Share Price</span> 
 
    </li><!-- end ngIf: profile.share_price && profile.offering_type.is_rega_plus --> 
 

 
    <!-- ngIf: profile.funding_round.security_type && (profile.funding_round.security_type == 'Convertible Note' || profile.funding_round.security_type == 'Crowd Note') && profile.funding_round.valuation_cap && !(check_int(profile.funding_round.investment_count) > 500) --> 
 

 
    <!-- ngIf: profile.funding_round.security_type && (profile.funding_round.security_type == 'Common Equity' || profile.funding_round.security_type == 'Preferred Equity') && profile.funding_round.pre_money_valuation && !(check_int(profile.funding_round.investment_count) > 500) --><li ng-if="profile.funding_round.security_type &amp;&amp; (profile.funding_round.security_type == 'Common Equity' || profile.funding_round.security_type == 'Preferred Equity') &amp;&amp; profile.funding_round.pre_money_valuation &amp;&amp; !(check_int(profile.funding_round.investment_count) > 500)" class="ng-scope"> 
 
    <!-- ngIf: check_int(profile.funding_round.pre_money_valuation) --><span ng-if="check_int(profile.funding_round.pre_money_valuation)" class="ng-binding ng-scope">$30,000,000 <br><span class="tooltip-link label" tooltip-placement="bottom-left" tooltip-html-unsafe="The valuation of the issuer prior to investments resulting from this offering.">Pre-Money valuation</span></span><!-- end ngIf: check_int(profile.funding_round.pre_money_valuation) --> 
 
    </li><!-- end ngIf: profile.funding_round.security_type && (profile.funding_round.security_type == 'Common Equity' || profile.funding_round.security_type == 'Preferred Equity') && profile.funding_round.pre_money_valuation && !(check_int(profile.funding_round.investment_count) > 500) --> 
 

 
    <!-- ngIf: profile.funding_round.security_type && !check_int(profile.funding_round.investment_total) && !check_int(profile.funding_round.reservation_total) --> 
 
</ul> 
 
<!-- ngIf: check_int(profile.funding_round.investment_total) --> 
 

 
<li ng-if="check_int(profile.funding_round.investment_total)" class="ng-binding ng-scope">$704,145<br><span class="label">Amount raised</span></li>

+0

ではなくhtmlファイルの一部を掲載しますが、より良いあなたの現在と一緒に対応するURLを提供したいですスクレイピングコード。 – TomS

答えて

0

あなたはただここから最後の値を取ることができます:

'<ul class="page-highlights no-bullet-list inline-list tight-list ng-scope" ng-if="profile.investability.action == \'invest\' || profile.investability.action == \'show_oversubscribed_warning\' || profile.investability.action == \'quiz_and_invest\' || !profile.investability.action || profile.investability.reason == \'anonymous\' || profile.offering_type.is_regcf || profile.investability.action == \'show_investment_summary\' || profile.investability.action == \'invest_interest\' || profile.investability.action == \'reserve\' || profile.investability.action == \'show_reservation_summary\' || profile.investability.action == \'submit_reservation\' || profile.investability.action == \'confirm_investment\'"> 
    <!-- ngIf: check_int(profile.funding_round.investment_total) --><li ng-if="check_int(profile.funding_round.investment_total)" class="ng-binding ng-scope">$704,145<br><span class="label">Amount raised</span></li><!-- end ngIf: check_int(profile.funding_round.investment_total) --> 

    <!-- ngIf: check_int(profile.funding_round.investment_count) > 500 --> 

    <!-- ngIf: check_int(profile.funding_round.reservation_total) --> 

    <!-- ngIf: profile.funding_round.min_investment_per_investor && !profile.offering_type.is_rega_plus --> 

    <!-- ngIf: profile.share_price && profile.offering_type.is_rega_plus --><li ng-if="profile.share_price &amp;&amp; profile.offering_type.is_rega_plus" class="ng-binding ng-scope"> 
    $0.50 <br><span class="label">Share Price</span> 
    </li><!-- end ngIf: profile.share_price && profile.offering_type.is_rega_plus --> 

    <!-- ngIf: profile.funding_round.security_type && (profile.funding_round.security_type == \'Convertible Note\' || profile.funding_round.security_type == \'Crowd Note\') && profile.funding_round.valuation_cap && !(check_int(profile.funding_round.investment_count) > 500) --> 

    <!-- ngIf: profile.funding_round.security_type && (profile.funding_round.security_type == \'Common Equity\' || profile.funding_round.security_type == \'Preferred Equity\') && profile.funding_round.pre_money_valuation && !(check_int(profile.funding_round.investment_count) > 500) --><li ng-if="profile.funding_round.security_type &amp;&amp; (profile.funding_round.security_type == \'Common Equity\' || profile.funding_round.security_type == \'Preferred Equity\') &amp;&amp; profile.funding_round.pre_money_valuation &amp;&amp; !(check_int(profile.funding_round.investment_count) > 500)" class="ng-scope"> 
    <!-- ngIf: check_int(profile.funding_round.pre_money_valuation) --><span ng-if="check_int(profile.funding_round.pre_money_valuation)" class="ng-binding ng-scope">$30,000,000 <br><span class="tooltip-link label" tooltip-placement="bottom-left" tooltip-html-unsafe="The valuation of the issuer prior to investments resulting from this offering.">Pre-Money valuation</span></span><!-- end ngIf: check_int(profile.funding_round.pre_money_valuation) --> 
    </li><!-- end ngIf: profile.funding_round.security_type && (profile.funding_round.security_type == \'Common Equity\' || profile.funding_round.security_type == \'Preferred Equity\') && profile.funding_round.pre_money_valuation && !(check_int(profile.funding_round.investment_count) > 500) --> 

    <!-- ngIf: profile.funding_round.security_type && !check_int(profile.funding_round.investment_total) && !check_int(profile.funding_round.reservation_total) --> 
</ul> 
<!-- ngIf: check_int(profile.funding_round.investment_total) --> 

<li ng-if="check_int(profile.funding_round.investment_total)" class="ng-binding ng-scope">$704,145<br><span class="label">Amount raised</span></li>' -> doc 

library(rvest) 

pg <- read_html(doc) 

html_nodes(pg, xpath=".//li[@ng-if='check_int(profile.funding_round.investment_total)']/br[1]/preceding-sibling::text()[1]") %>% 
    html_text() 
## [1] "$704,145" "$704,145" 
関連する問題