在google中使用Importxml。
当信息不是div类或div id时,如何从这里获得“数据-胶片-id”和“数据-胶片-发行年”?:
<div class="react-component film-poster film-poster-193260 poster linked-film-poster -attributed"
data-component-class="globals.comps.FilmPosterComponent"
data-film-id="193260"
data-film-name="The Choice"
data-poster-url="/film/the-choice-1987/image-150/"
data-film-release-year="1987"
data-film-link="/film/the-choice-1987/" 我能够从网站( A1是[https://letterboxd.com/tag/30-countries-2018/diary/by/added/page/58/])获取一些信息到google中,使用如下:
=ImportXML(A1, "//div[contains(@class,'react-component') and contains(@class,'film-poster')]/a/@href")所以我知道一切都正常,但那只是因为href在它自己的段落中低于这个div。我的问题是试图挖掘上面显示的信息。
在这个站点上搜索之后,我尝试了这个(包括许多其他事情),但是它导致了一个错误。
=ImportXML(A1, "//li[@class='poster-container']//div[not(@id) or not(@class)]")但它给了我已经有的信息,而不是我需要的信息。
也许我不能得到日期,因为它不是一门课或一个身份证?
发布于 2018-04-05 03:04:01
您需要使用属性选择器。
=ImportXML(A1, "//div[contains(@class,'react-component') and contains(@class,'film-poster')]/attribute::data-film-id")因此,在B栏中,您可以使用上面的公式来显示胶片ID,在C栏中显示发行年份的另一个公式,以此类推。
如果你想把一切都排在一排,而我不建议这样做,那就是
=ImportXML(A1, "//div[contains(@class,'react-component') and contains(@class,'film-poster')]/attribute::data-film-id | //div[contains(@class,'react-component') and contains(@class,'film-poster')]/attribute::data-film-release-year")我不建议将其合并,因为它在一列“年份,id,.”中输出所有内容。很乱。
https://stackoverflow.com/questions/49663019
复制相似问题