This function is used to scrape text paragraphs from a website.
paragraphs_scrap( link, contain = NULL, case_sensitive = FALSE, collapse = FALSE, askRobot = FALSE )
link | the link of the web page to scrape |
---|---|
contain | filter the paragraphs according to the character string provided. |
case_sensitive | logical. Should the contain argument be case sensitive ? defaults to FALSE |
collapse | if TRUE the paragraphs will be collapsed into one element and the contain argument ignored. |
askRobot | logical. Should the function ask the robots.txt if we're allowed or not to scrap the web page ? Default is FALSE. |
a character vector.
# \donttest{ # Extracting the paragraphs displayed on the health page of the New York Times link <- "https://www.nytimes.com/section/health" paragraphs_scrap(link)# }#> [1] "Supported by" #> [2] "Administrators and young graduate students have been inoculated at leading research hospitals, contrary to state and federal guidelines." #> [3] "By Apoorva Mandavilli" #> [4] "Some states are already expanding eligibility to people 65 and over, even though millions of people the C.D.C. recommends go first — health care workers and nursing home residents — have yet to get shots." #> [5] "By Abby Goodnough" #> [6] "Appointed head of the incoming administration’s task force on health equity, the Yale University scientist “is not sitting in her ivory tower.”" #> [7] "By Roni Caryn Rabin" #> [8] "A large study of patients from a Wuhan, China hospital showed that a half-year later, three-quarters were struggling with problems like fatigue, depression and diminished lung function." #> [9] "By Pam Belluck" #> [10] "Reports of a highly contagious new variant, published on Friday by multiple news outlets, were based on speculative statements made by Dr. Deborah Birx." #> [11] "By Apoorva Mandavilli" #> [12] "It’s good news, but experts cautioned that the new variants from Britain and South Africa also carry other potentially dangerous mutations that have not yet been investigated." #> [13] "By Carl Zimmer" #> [14] "An outbreak aboard a September flight from Dubai to New Zealand offers researchers, and airlines, an opportunity to study in-transit contagion." #> [15] "By Benedict Carey" #> [16] "Some scientists fear that the mayhem on Capitol Hill may prove to have been a so-called super-spreading event." #> [17] "By Apoorva Mandavilli" #> [18] "See how the leading vaccines train the immune system to fight the virus." #> [19] "By Jonathan Corum and Carl Zimmer" #> [20] "Advertisement" #> [21] "Removing obstacles makes it more likely you’ll achieve a new health goal. The 7-Day Well Challenge will show you how." #> [22] "By Tara Parker-Pope" #> [23] "Whether it’s a person or an app that sends us reminders, we make better choices when we’re being watched (even by ourselves.)" #> [24] "By Tara Parker-Pope" #> [25] "An important lesson of 2020 is that preparation for a health crisis is a gift to the people you love. Today’s Well challenge shows you how." #> [26] "By Tara Parker-Pope" #> [27] "Our 7-Day Well Challenge will show you how to build on the healthy habits you learned during pandemic life." #> [28] "By Tara Parker-Pope" #> [29] "During pandemic lockdowns, many of us learned the importance of short home workouts. Take the 7-Day Well Challenge for a new exercise video and more ways to keep moving in 2021." #> [30] "By Tara Parker-Pope" #> [31] "Los programas de muchos países se han visto obstaculizados por la lentitud de las burocracias, la falta de enfermeros y la escasez del equipo indispensable." #> [32] "By Marc Santora" #> [33] "Sole proprietors were eligible for loans under the Paycheck Protection Program only if they were profitable, but many got tiny loans because of the way rules were written." #> [34] "By Stacy Cowley" #> [35] "A game between the Miami Heat and the Boston Celtics was postponed and several teams have been left without key players because of players’ testing positive for the coronavirus and contact tracing." #> [36] "By Sopan Deb" #> [37] "Florida decided people 65 and older should get the coronavirus vaccine first. But demand has overwhelmed supply, and people are frustrated." #> [38] "By Patricia Mazzei, Eric Adelson and Kate Kelly" #> [39] "The Chinese Communist Party’s efforts to hide its missteps have taken on new urgency as the anniversary of the world’s first Covid-19 lockdown nears." #> [40] "By Amy Qin and Javier C. Hernández" #> [41] "Advertisement" #> [42] "New world. New rules. Same old problems." #> [43] "By Valeriya Safronova" #> [44] "This week, learn about the basics of perfume, listen to a string quartet or catch Regina King’s directorial debut." #> [45] "By Katherine Cusumano and Emma Grillo" #> [46] "Starting a new habit is hard. To make it easier, try recycling an old one instead, building on lessons you learned from pandemic living." #> [47] "By Tara Parker-Pope" #> [48] "The Trump administration’s move, which Biden could eventually reverse, would loosen program rules and cap the state’s funding as part of a block grant." #> [49] "By Margot Sanger-Katz" #> [50] "Public health officials are using Eventbrite’s online ticketing platform to schedule shots. But appointments are still hard to find, and not everyone knows how to use the website." #> [51] "By Jacey Fortin" #> [52] "The big dip in mortality shown in the trial of about 800 patients has caught some experts by surprise because previous studies of the drugs showed little benefit." #> [53] "By Katherine J. Wu" #> [54] "Many people want a pandemic baby, but some sperm banks are running low. So women are joining unregulated Facebook groups to find willing donors, no middleman required." #> [55] "By Nellie Bowles" #> [56] "The babysitter says she has nine days sober, but we all lie, every addict, every alcoholic." #> [57] "By Sarah Twombly" #> [58] "Test your knowledge of this week’s health news." #> [59] "By Toby Bilanow" #> [60] "By Roni Caryn Rabin" #> [61] "Advertisement" #> [62] "Advertisement"