R:html_nodes在网站上复制内容

问题描述

html_nodes在网站上复制内容时遇到了一个奇怪的问题。

这是基本代码

# I bring in a sample URL with a lot of CSS and Javascript
address <- "https://www.speedtest.net/"
content <- read_html(URLencode(address))
content %>%
    # I want to analyze the words on the page,so I bring in the body.
    html_nodes("body") %>%
    # I don't want Javascript and CSS cluttering the analysis,so I remove them
    html_nodes(":not(script)") %>%
    html_nodes(":not(style)") %>%
    html_text

html_nodes(“:not(script)”)有效地消除了Javascript的混乱情况。 但是,由于某种原因,它还会复制网站上的每一行文字,这样我的最终输出应如下所示:

网络状态网络状态隐私政策隐私政策条款 使用使用条款不出售我的个人信息 不出售我的个人信息

我觉得这只是我的语法错误。谁知道怎么修它?还是有一种更聪明的方法来达到相同的结果?

谢谢!

解决方法

您可能会这样考虑:

$query = mysqli_query($con,"INSERT INTO users VALUES ('','$name','$username','$email','$pass','$gender','$profile_pic','$date','$vkey','','0','no',','0')");
$query2 = mysqli_query($con,"INSERT INTO profilepage1 (username) VALUES('$username')");
$query3 = mysqli_query($con,"INSERT INTO profilepage2 (username) VALUES('$username')");