Google表格上的ImportXML-如何获取用户变量(种类)?

时间:2018-07-12 14:33:33

标签: xpath google-sheets

通过{p> 3导入rateyourmusic.com上任何演员的电影作品后

=importxml("https://rateyourmusic.com/films/cary_grant/","//li")

我不知道如何为某些标题检索自己的用户等级(这还会告诉我我已经看过的列表中的哪个标题)。

由于我仍在学习关于importxml命令的绳索,所以我发现所有绳索都在'film_cat_catalog_msg_1050' Xpath标识符(?)下,但摆弄了上述命令,所有我可以在电子表格的另一列上找到标准的“费率”一词,但没有个人评分。

有人可以帮我吗?

<li><span onclick="RYMartistPage.openFilmCataloger(1050);" class="disco_cat_inner"><span class="disco_cat_catalog_msg"><i class="fa fa-caret-left"></i> </span> <span id="film_cat_catalog_msg_1050">4.5</span></span><div id="film_cataloger_1050" class="film_cataloger"><div class="film_cataloger_close" onclick="RYMartistPage.collapseFilmCataloger(1050);"><i class="fa fa-caret-right"></i> </div> <div id="film_cataloger_content_1050" class="film_cataloger_content"></div></div>
     <div class="has_tip film_rel_img delayed_discography_img" data-delayloadurl="url('//e.snmc.io/lk/m/l/45956edc922ce07e2b84a6ff23da3452/6152891.jpg')" data-delayloadurl2x="url('//e.snmc.io/lk/t/l/48b945e1a503ab7a9dce538a50fa9b99/6152891.jpg')" style="background: rgba(0, 0, 0, 0) url(&quot;//e.snmc.io/lk/t/l/48b945e1a503ab7a9dce538a50fa9b99/6152891.jpg&quot;) repeat scroll 0% 0%;"></div><div class="disco_avg_rating">3.81</div><div class="disco_ratings">1,063</div><div class="disco_reviews">25</div>     <div class="film_info">    
     <div class="film_mainline recommended">
        <a title="[Film1050]" href="/film/his_girl_friday/" class="film">His Girl Friday</a>
     </div>
     <div class="film_subline">
     <span title="18 January 1940 " class="disco_year_ymd">1940</span> • Walter Burns 
     </div>
     </div></li>

您必须先登录才能查看上述评分,这是非会员的屏幕截图:

rateyourmusic.com filmography

1 个答案:

答案 0 :(得分:0)

尝试使用此XPath查询:

//span[@id="film_cat_catalog_msg_1050"]

Demo


您已经猜到了,由于数字部分实际上是可变的,因此我们需要starts-with之类的东西:

//span[starts-with(@id, "film_cat_catalog_msg_")]

Demo 2

将它们放在一起:

=importxml("https://rateyourmusic.com/films/cary_grant/","//span[starts-with(@id, 'film_cat_catalog_msg_')]")