首页 \ 问答 \ 使用R刮擦,只在列表中抓取第一个实例[关闭](Scraping with R, only first instance being scraped in the list [closed])

使用R刮擦,只在列表中抓取第一个实例[关闭](Scraping with R, only first instance being scraped in the list [closed])

我已经抓了几个网站,并没有真正对我的输出有问题,但我不明白为什么在这个特定的网站上我只得到我试图刮去而不是所有36的第一个实例。

我正在尝试收集页面上所有玩家的href链接,并将它们保存到列表或数据框中。

我目前的代码是:

library(XML)
library(rvest)
match <- "https://www.fotball.no/fotballdata/kamp/?fiksId=6616922"
WSm <- read_html(match)
Players <- WSm %>% html_node(".player-name") %>% html_attr("href") %>% as.character()

这给了我:

[1] "/fotballdata/person/profil/?fiksId=2820074"

不是我所期望的所有玩家的所有href的完整列表。 谁能帮忙?


I have scraped a few websites and haven't really had a problem with my outputs but I don't understand why on this particular website I am only getting the 1st instance of what I am trying to scrape instead of all 36.

I am trying to collect the href links for all players on the page and save them to a list or dataframe.

My current code is:

library(XML)
library(rvest)
match <- "https://www.fotball.no/fotballdata/kamp/?fiksId=6616922"
WSm <- read_html(match)
Players <- WSm %>% html_node(".player-name") %>% html_attr("href") %>% as.character()

This gives me:

[1] "/fotballdata/person/profil/?fiksId=2820074"

Not the full list of all hrefs for all players as I am expecting. Could anyone help?


原文:https://stackoverflow.com/questions/39258944
更新时间:2021-09-24 21:09

最满意答案

尝试使用find

find -iname makefile -execdir make -f {} \;

这将找到每个文件名为makefile (或Makefile,或者任何不同的单词makefile的情况,感谢thiton)(递归)然后启动make对它。


Try with find :

find -iname makefile -execdir make -f {} \;

That will find every file named makefile (or Makefile, or whatever different case for word makefile, thanks to thiton) (recursively) and then launch make against it.

相关问答

更多
  • 这将递归为您做: find /path/to/base/dir/* -type d -ctime +10 -exec rm -rf {} \; 说明: find :查找文件/目录/链接等的unix命令 /path/to/base/dir :开始搜索的目录。 -type d :只找到目录 -ctime +10 :只考虑修改时间超过10天的那些 -exec ... \; :对于每个这样的结果,请在...执行以下命令 rm -rf {} :递归强制删除目录; {}部分是从上一部分找到结果的地方。 或者,使用: ...
  • 如果当前目录包含目录“v_79”,那么 for dir in v_79/dir_{0..210}/ENSG00000??????; do mkdir $dir/my_dir; done 我想知道这是否会给你一个“参数列表太长”的错误,在这种情况下, find是要走的路。 if your current directory contains directory "v_79", then for dir in v_79/dir_{0..210}/ENSG00000??????; do mkdir $dir/m ...
  • 你可以用find 。 myShell.sh脚本可能看起来有点像这样,这是一个递归处理目标下任何和所有子目录的版本。 DIR="$1" find "$DIR" -type d -exec java myProg {} \; 可用的确切find选项集取决于您的各种unix。 如果你不想要递归,你可以使用-maxdepth作为Neeraj注意到,或者也许-prune ,它开始变得有点难看: find "$DIR" \( ! -name . -prune \) -type d -exec java myProg ...
  • 我的猜测是你要深入两个层次,但只能回到一个层次。 尝试在ls之后添加cd ../.. ,或者使用pushd和popd来代替。 例如: for dir in $dirlist do pushd $dir echo $dir ls popd done 正如@shellter指出的那样,如果这些目录有空格,那么类似这样的东西可能会更好: find $1 -mindepth 1 -maxdepth 1 -type d | while read -r dir do pushd "$dir" # ...
  • 显示您所询问的信息的最简单方法是使用您希望以分层形式查看所有内容的目录中的$ tree命令。 如果还没有安装(如果使用linux应该是) $ sudo apt update $ sudo apt upgrade $ sudo apt install tree 如果使用mac $ brew update $ brew upgrade $ brew install tree 此命令将显示所有目录,即运行tree命令的目录下的子目录 希望这可以帮助 The easiest way to display th ...
  • 它只保存脚本所在的目录: DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" commandA && commandB条件的计算方式如下: 当且仅当commandA返回退出状态为零时,才执行commandB 。 作为cd something ,如果dir存在,它将返回true。 如果不是,它将返回退出状态false,因此不会执行pwd 。 从图形上看,它可以解释为: DIR="$( cd "$( dirname "${BASH_SOURCE[0] ...
  • 尝试使用find : find -iname makefile -execdir make -f {} \; 这将找到每个文件名为makefile (或Makefile,或者任何不同的单词makefile的情况,感谢thiton)(递归)然后启动make对它。 Try with find : find -iname makefile -execdir make -f {} \; That will find every file named makefile (or Makefile, or whate ...
  • 在csh : foreach d (case*) $d/script & end 或者您可以使用sh / bash ,它提供了更好的编程接口: for d in case*; do $d/script & done 如果要在执行脚本时进入目录,请在运行脚本之前添加cd 。 In csh: foreach d (case*) $d/script & end Or you can use sh/bash which gives a better programatic interface: for ...
  • find命令在这些方面非常强大,请尝试: find videos/ -name "*.mp4" -exec ffmpegScript {} \; 这将查找.mp4结尾的所有文件(也在子目录中)并执行ffmpegScript nameOfMp4File ,其中nameOfMp4File是找到的文件的名称,一次一个。 find照顾循环本身。 现在我们需要定义ffmpegScript : #!/usr/bin/env bash inputFile="$1" outputFile="$(dirname $1)" ...
  • 像/var/www/html/my.domain.com/v*这样的全局模式是一种bash功能。 当您使用sh script.sh启动脚本时,bash似乎不是系统上的默认shell。 确保使用bash启动脚本: bash script.sh 如果您要使用chmod +x script.sh直接使脚本可执行,请确保您不会错过在第一行中使用以下shebang : #!/bin/bash Glob patterns like /var/www/html/my.domain.com/v* are a bash ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)