library(tidyverse)
library(newsanchor)
library(printr)
library(httr)
library(jsonlite)
News API
Es gibt eine Seite News API, die es erlaubt, per API News (Artikel, Schlagzeilen) von weltweiten Quellen herunterzuladen, per JSON API.
Gibt’s da auch ein R-Paket?
Ja - NewsAnchor.
Setup
Zuerst muss man sich bei der Seite eine API Key holen, für Entwicklerzwecke kostenlos. Komfortabel ist, sich den Schlüssel in die R-environment-Datei (.Renviron
) zu schreiben, s. hier für mehr Infos.
Das kann man z.B. so machen:
newsanchor::set_api_key(path = "~/.Renviron")
So fragt man den API-Schlüssel dann ab:
my_api_key <- Sys.getenv("NEWS_API_KEY")
Abfrage
results <- get_everything(query = "Corona",
language = "de")
results_main <- results$results_df
In eine Datei schreiben:
saveRDS(results, file = "newsanchor1.rds")
Und wieder laden:
results <- read_rds("newsanchor1.rds")
Abfrage 2
results_covid <- get_everything(query = "Covid",
language = "en")
write_rds(results_covid,
file = "results_covid1.rds")
results_covid <- read_rds(file = "results_covid1.rds")
Metadata:
results_covid$metadata
total_results | status_code | request_date | request_url | code | message | page | page_size |
---|---|---|---|---|---|---|---|
175517 | 200 | 2021-07-07 10:04:28 | https://newsapi.org/v2/everything?q=Covid&language=en&sortBy=publishedAt&pageSize=100&page=1 | 1 | 100 |
Ergebnisse:
results_covid$results_df %>%
slice(1:2)
author | title | description | url | url_to_image | published_at | content | id | name |
---|---|---|---|---|---|---|---|---|
Colm Quinn | Saudi Arabia’s Hushed Washington Visit | The visit of Khalid bin Salman has been met with little fanfare and proves Saudi Arabia is far from the “pariah” of Biden’s campaign pledge. | https://foreignpolicy.com/2021/07/07/saudi-arabia-washington-khalid-bin-salman/ | https://foreignpolicy.com/wp-content/uploads/2021/07/saudi-arabia-GettyImages-1170949600.jpg?w=1000 | 2021-07-07 09:53:28 | Here is todays Foreign Policy brief: Prince Khalid bin Salman continues Washington visit, the United Nations calls for talks on Ethiopian dam dispute, and Iran takes steps to produce enriched uranium… [+6709 chars] | NA | Foreign Policy |
NA | District in central Israel labeled ‘Red’ due to high infection rate | Israel’s Ministry of Health declared the city of Kfar Yona in the center of the country as a “Red” - or highly contagious - city due to a recent spike in local COVID cases.The Hod Hasharon district received the second worst “Orange” label, as 20 new patients … | https://www.israelnationalnews.com/News/Flash.aspx/546065 | http://u.a7.org/pictures/799/799624.jpg | 2021-07-07 09:52:57 | Israel’s Ministry of Health declared the city of Kfar Yona in the center of the country as a “Red” - or highly contagious - city due to a recent spike in local COVID cases. | ||
The Hod Hasharon district… [+189 chars] | NA | Israelnationalnews.com |
Aufbereiten
results_covid_short <-
results_covid$results_df %>%
select(author, title, content, published_at, name) %>%
drop_na()
results_covid_short %>%
slice(1:2)
author | title | content | published_at | name |
---|---|---|---|---|
Colm Quinn | Saudi Arabia’s Hushed Washington Visit | Here is todays Foreign Policy brief: Prince Khalid bin Salman continues Washington visit, the United Nations calls for talks on Ethiopian dam dispute, and Iran takes steps to produce enriched uranium… [+6709 chars] | 2021-07-07 09:53:28 | Foreign Policy |
soyacincau | 1 Utama: WhatsApp message claiming over 50 people infected with Delta variant is fake news | The management of 1 Utama Shopping Centre today denied that any of its personnel or patrons have become infected with the highly contagious new strain of COVID-19 known identified as Delta. | ||
In a Fac… [+814 chars] | 2021-07-07 09:51:45 | SoyaCincau.com |
write_csv(results_covid_short,
file = "news_covid_short.csv")
Quellen
Hier ist eine Liste der unterstützen Quellen:
terms_sources
sources |
---|
abc-news |
abc-news-au |
aftenposten |
al-jazeera-english |
ansa |
argaam |
ars-technica |
ary-news |
associated-press |
australian-financial-review |
axios |
bbc-news |
bbc-sport |
bild |
blasting-news-br |
bleacher-report |
bloomberg |
breitbart-news |
business-insider |
business-insider-uk |
buzzfeed |
cbc-news |
cbs-news |
cnbc |
cnn |
cnn-es |
crypto-coins-news |
daily-mail |
der-tagesspiegel |
die-zeit |
el-mundo |
engadget |
entertainment-weekly |
espn |
espn-cric-info |
financial-post |
financial-times |
focus |
football-italia |
fortune |
four-four-two |
fox-news |
fox-sports |
globo |
google-news |
google-news-ar |
google-news-au |
google-news-br |
google-news-ca |
google-news-fr |
google-news-in |
google-news-is |
google-news-it |
google-news-ru |
google-news-sa |
google-news-uk |
goteborgs-posten |
gruenderszene |
hacker-news |
handelsblatt |
ign |
il-sole-24-ore |
independent |
infobae |
info-money |
la-gaceta |
la-nacion |
la-repubblica |
le-monde |
lenta |
lequipe |
les-echos |
liberation |
marca |
mashable |
medical-news-today |
metro |
mirror |
msnbc |
mtv-news |
mtv-news-uk |
national-geographic |
national-review |
nbc-news |
news24 |
new-scientist |
news-com-au |
newsweek |
new-york-magazine |
next-big-future |
nfl-news |
nhl-news |
nrk |
politico |
polygon |
rbc |
recode |
reddit-r-all |
reuters |
rt |
rte |
rtl-nieuws |
sabq |
spiegel-online |
svenska-dagbladet |
t3n |
talksport |
techcrunch |
techcrunch-cn |
techradar |
the-american-conservative |
the-economist |
the-globe-and-mail |
the-guardian-au |
the-guardian-uk |
the-hill |
the-hindu |
the-huffington-post |
the-irish-times |
the-jerusalem-post |
the-lad-bible |
the-new-york-times |
the-next-web |
the-sport-bible |
the-telegraph |
the-times-of-india |
the-verge |
the-wall-street-journal |
the-washington-post |
the-washington-times |
time |
usa-today |
vice-news |
wired |
wired-de |
wirtschafts-woche |
xinhua-net |
ynet |
Mit GET-Abfrage
So setzt man die Abfrage zusammen, bzw. so kann man es tun:
Beispiel: Alle Artikel über Tesla aus dem letzten Monat, sortiert nach dem neuesten
apiurl <-
"https://newsapi.org/v2/everything?"
Suchbegriff:
term <- "q=tesla"
Zeitraum begrenzen:
from_to <- "&from=2021-06-07"
Sortieren:
sortby <- "&sortBy=publishedAt"
API-Schlüssel:
apikey <- paste0("&apiKey=",my_api_key)
In tutto:
GET_term <- paste0(apiurl,
term,
from_to,
sortby,
apikey
)
tesla_news <-
GET(url = GET_term)
write_rds(tesla_news,
file = "tesla_news.rds")
tesla_news <- read_rds("tesla_news.rds")
tesla_news$status_code
See here the HTTP status codes.
200 means success, everything above is not so good.
tesla_content <-
fromJSON(rawToChar(tesla_news$content))
names(tesla_content)
## [1] "status" "totalResults" "articles"
tesla_content$articles %>%
select(-source)
author | title | description | url | urlToImage | publishedAt | content |
---|---|---|---|---|---|---|
Wall Street Breakfast | Wall Street Breakfast: What Were They Thinking? | Listen on the go! A daily podcast of Wall Street Breakfast will be available by 8:00 a.m. on Seeking Alpha, iTunes, Stitcher and Spotify. | https://seekingalpha.com/article/4438128-wall-street-breakfast-what-thinking | https://static.seekingalpha.com/uploads/2021/7/2/si_water_2021_630x220_shaq_v1.jpg | 2021-07-07T11:16:43Z | Listen on the go! A daily podcast of Wall Street Breakfast will be available by 8:00 a.m. on Seeking Alpha, iTunes, Stitcher and Spotify. |
-
BioNTech/Pfizer:… [+592 chars] | |tlevin@businessinsider.com (Tim Levin) |A supply crunch has sent used car prices sky high. These 16 models are now worth more used than new |Used car prices have soared so much in recent months that some in-demand models are thousands of dollars cheaper to buy new. |https://www.businessinsider.com/used-cars-more-expensive-than-new-auto-industry-chip-shortage-2021-7 |https://i.insider.com/60e4bb8e22d19400191c94c6?width=1200&format=jpeg |2021-07-07T10:35:00Z |Skipping a brand-new car for one that’s lightly used has always been the most wallet-friendly way of going about things. Not anymore. In the strange and sometimes utterly backward-seeming times we’… [+3784 chars] | |NA |Global and China Passenger Car T-Box Market Report 2021: In 2020, Passenger Car T-Box Increased by 25.4% y-o-y, and the Proportion of 5G T-Box Jumped - ResearchAndMarkets.com |DUBLIN–(BUSINESS WIRE)–The “Global and China Passenger Car T-Box Market Report, 2021” report has been added to ResearchAndMarkets.com’s offering. In 2020, passenger car T-Box increased by 25.4% year-on-year, and the proportion of 5G T-Box jumped Global and … |https://www.businesswire.com/news/home/20210707005441/en/Global-and-China-Passenger-Car-T-Box-Market-Report-2021-In-2020-Passenger-Car-T-Box-Increased-by-25.4-y-o-y-and-the-Proportion-of-5G-T-Box-Jumped---ResearchAndMarkets.com |https://mms.businesswire.com/media/20210707005441/en/371054/23/ResearchAndMarkets_800px.jpg |2021-07-07T10:24:59Z |DUBLIN–(BUSINESS WIRE)–The “Global and China Passenger Car T-Box Market Report, 2021” report has been added to ResearchAndMarkets.com’s offering. In 2020, passenger car T-Box increased by 25.4% ye… [+5306 chars] | |Abdullah |Jeff Bezos became the richest person with a record fortune of $211 billion |The richest man in the world, Jeff Bezos, now has a fortune of $ 211 billion as Amazon shares surged 4.7% after the Pentagon announced … The post Jeff Bezos became the richest person with a record fortune of $211 billion appeared first on Gizchina.com. |https://www.gizchina.com/2021/07/07/jeff-bezos-became-the-richest-person-with-a-record-fortune-of-211-billion/ |https://www.gizchina.com/wp-content/uploads/images/2021/07/skynews-jeff-bezos-amazon_5437859-1024x576.jpg |2021-07-07T10:24:20Z |The richest man in the world, Jeff Bezos, now has a fortune of $ 211 billion as Amazon shares surged 4.7% after the Pentagon announced the cancellation of its cloud computing contract with Microsoft.… [+2292 chars] | |Oliver Schwuchow |Polestar 4: Vom Precept-Konzept zum Elektro-Flaggschiff |Mit dem Polestar 1 gab es einen Hybrid-Sportwagen, bevor sich Volvo später dazu entschied, dass Polestar direkt eine rein elektrische Marke wird. Mit dem Polestar […] |https://www.mobiflip.de/shortnews/polestar-4-precept-elektro-flaggschiff/ |https://i0.wp.com/www.mobiflip.de/wp-content/uploads/2021/07/polestar-4-precept-header.jpg?fit=1200%2C825&ssl=1 |2021-07-07T10:20:52Z |Mit dem Polestar 1 gab es einen Hybrid-Sportwagen, bevor sich Volvo später dazu entschied, dass Polestar direkt eine rein elektrische Marke wird. Mit dem Polestar 2 greift man aktuell das Tesla Model… [+1594 chars] | |1023 |Состояние Безоса достигло рекордных $211 млрд |Предыдущий рекорд принадлежал Илону Маску - в январе 2021 года его состояние оценили в $210 млрд, однако сейчас оно составляет $181 млрд. |https://korrespondent.net/business/companies/4374725-sostoianye-bezosa-dostyhlo-rekordnykh-211-mlrd |https://kor.ill.in.ua/m/190x120/2640527.jpeg |2021-07-07T10:20:00Z |Amazon $211 . Daily Mail , 7 . 2021 - Tesla SpaceX 210 . 181 . 8,4 , Amazon 4,7% , $10 Microsoft JEDI . , Amazon. , Amazon Web Services. . .net Telegram. https://t.me/korrespondentnet | |Sahil Gupta |Elon Musk Says Tesla Plaid UI Coming To Model 3 & Y With FSD Release |While there is still no timeline for these updates, the new Tesla Model S Plaid has launched with a new user interface which Musk calls “mind of car”. |https://www.carandbike.com/news/elon-musk-says-tesla-plaid-ui-coming-to-model-3-y-with-fsd-release-2481266 |https://c.ndtvimg.com/2021-05/ceovoesg_elon-musk-bloomberg_625x300_13_May_21.jpg |2021-07-07T10:19:45Z |Elon Musk Says Tesla Plaid UI Coming To Model 3 & Y With FSD Release Tesla supremo, Elon Musk has revealed that the full self-driving beta, dubbed FSD9 is coming soon to the owners of the Tesla M… [+2055 chars] | |snagarajan@businessinsider.com (Shalini Nagarajan) |10 things you need to know before the opening bell |This is what traders are talking about. |https://markets.businessinsider.com/news/stocks/opening-bell-july-7-2021-7 |https://images2.markets.businessinsider.com/60e579de85fa1700185226b2?format=jpeg |2021-07-07T10:17:30Z |Spencer Platt/Getty Images Welcome to 10 Things Before the Opening Bell. Sign up here to get the day’s top stock and crypto news in your inbox every morning. Sign up for Insider Investing for your … [+1582 chars] | |Emiliano Ragoni |Volkswagen: le elettriche ID si aggiorneranno come uno smartphone |Volkswagen come Tesla: le elettriche ID si aggiorneranno come uno smartphoneLa Volkswagen lancia ufficialmente gli aggiornamenti Ota, Over-the-Air, per la famiglia delle sue elettriche ID. Il primo grande aggiornamento, che migliorerà anche le prestazioni del… |https://www.gazzetta.it/motori/mobilita-sostenibile/auto-elettriche/07-07-2021/volkswagen-come-tesla-elettriche-id-si-aggiorneranno-come-smartphone-4102522002478.shtml |https://images2.gazzettaobjects.it/methode_image/2021/07/05/Motori/Foto_Motori_-_Trattate/7ce5a658-dda1-11eb-9fcb-0d4bf680ad4c_1200x675.jpg?v=202107071217 |2021-07-07T10:16:50Z |Emiliano Ragoni @EmilianoRagoni 7 luglio - Milano La Volkswagen lancia ufficialmente gli aggiornamenti Ota, Over-the-Air, per la famiglia delle sue elettriche ID. La casa tedesca, do… [+3012 chars] | |Thibaut Emme |La France anticipe les véhicules à conduite automatisée |Les différents codes de la route dans le monde n’ont pas prévu l’arrivée des véhicules plus ou moins autonomes. La France est le premier pays en Europe à se doter d’un cadre réglementaire pour anticiper l’arrivée prochaine de ces véhicules. Depuis mai 2018, l… |https://www.leblogauto.com/2021/07/france-anticipe-vehicules-a-conduite-automatisee.html |https://leblogauto.b-cdn.net/wp-content/uploads/2021/07/voiture_robots.jpg |2021-07-07T10:15:50Z |Les différents codes de la route dans le monde n’ont pas prévu l’arrivée des véhicules plus ou moins autonomes. La France est le premier pays en Europe à se doter d’un cadre réglementaire pour antici… [+6474 chars] | |Scott Carpenter and Sophie Alexander / Bloomberg |Jeff Bezos Is the Richest Person Ever After His Net Worth Soars to $211 Billion |Amazon stock rallied Tuesday and raised Bezos’s fortune by $8.4 billion, according to the Bloomberg Billionaires Index. |https://time.com/6078311/jeff-bezos-net-worth-record/ |https://api.time.com/wp-content/uploads/2021/07/Jeff-Bezos-net-worth.jpg?quality=85&w=1024&h=628&crop=1 |2021-07-07T10:13:34Z |Jeff Bezos is leaving the rest of the world behind when it comes to wealth accumulation. The world’s richest man reached a record $211 billion net worth Tuesday after Amazon.com shares rose 4.7% aft… [+1920 chars] | |Claire Rodineau |Partir en vacances, le stress en moins : on a testé l’offre Covid d’une conciergerie privée |Vous redoutez de ne pas avoir votre PCR à temps, cauchemardez à l’idée des files d’attente à l’aéroport cet été ? Les entreprises de conciergerie privée, hybrides entre l’agent de voyages et l’assistant personnel de luxe, proposent d’aider les estivants à déc… |https://www.lefigaro.fr/voyages/partir-en-vacances-le-stress-en-moins-on-a-teste-l-offre-covid-d-une-conciergerie-privee-20210707 |https://i.f1g.fr/media/cms/704x396_cropupscale/2021/07/06/64eb963a56ccba643ee34c6ff407b9049a4e6d6ef860c9e375fcb4ae19a0bf90.jpg |2021-07-07T10:10:22Z |Vous redoutez de ne pas avoir votre PCR à temps, cauchemardez à l’idée des files d’attente à l’aéroport cet été ? Les entreprises de conciergerie privée, hybrides entre l’agent de voyages et l’assist… [+6019 chars] | |Sostav.ru |Volvo станет брендом электрокаров премиум-класса |Компания заявила о планах по захвату рынка электромобилей |https://www.sostav.ru/publication/volvo-elektromobili-49309.html |https://www.sostav.ru/images/news/2021/07/07/preview/49309_social.jpg?rnd=756260 |2021-07-07T10:10:00Z |Volvo , - , - . , Volvo, « , -, ». , , . 1,2 , . Tesla, Volvo, Model S Plaid. , « Porsche Volvo». , 96,5 /, 320 /. | |Bolsamania |Consultorio de análisis técnico: IAG, Telefónica, Inditex, Meliá, Aryzta, Wirecard, Netflix y Tesla |A continuación, damos respuesta a los valores por los que más nos han preguntado a lo largo de la mañana. José María Rodríguez, analista técnico de Bolsamanía, analiza Meliá Hotels, Tesla, Telefónica, Inditex, Aryzta, Wirecard, IAG y Netflix. |https://www.bolsamania.com/noticias/analisis-tecnico/consultorio-analisis-tecnico-iag-telefonica-inditex-melia-aryzta-wirecard-netflix-tesla--8029937.html |https://img.s3wfg.com/web/img/images_uploaded/b/6/broker710345a.gif |2021-07-07T10:05:38Z |A continuación, damos respuesta a los valores por los que más nos han preguntado a lo largo de la mañana. José María Rodríguez, analista técnico de Bolsamanía, analiza Meliá Hotels, Tesla, Telefónica… [+7790 chars] | |NA |Alman ZDF: Türkiye’nin Otomobili Volkswagen’e rakip mi? |Alman Televizyonu ZDF, TOGG haberinde Türkiye’nin gücünü birleştirerek iddialı bir hedefe doğru ilerlediğine vurgu yaptı. - Anadolu Ajansı |https://www.aa.com.tr/tr/dunya/alman-zdf-turkiye-nin-otomobili-volkswagen-e-rakip-mi/2296761 |https://cdnuploads.aa.com.tr/uploads/Contents/2021/07/07/thumbs_b_c_c627bf7c33debb62427b1e4acefc3df2.jpg |2021-07-07T10:01:11Z |Türkiye’nin Otomobili Giriim Grubu’nun (TOGG) üretecei elektrikli otomobillere Alman basnnda geni yer verildi. Alman Televizyon Kanal ZDF, “Türkiye’nin Otomobili, Tesla ve Volkswagen’e rakip mi?” ba… [+3393 chars] | |and |Hádanka je rozuzlená. Bugatti a Rimac vytvoria spoločný podnik! |Nová spoločnosť Bugatti-Rimac vzniká pod taktovkou Porsche. Koncern VW sa tak svojho klenotu nevzdá. |https://auto.pravda.sk/magazin/clanok/593758-hadanka-je-rozuzlena-bugatti-a-rimac-vytvoria-spolocny-podnik/ |http://ipravda.sk/res/2021/07/06/thumbs/bugatti-rimac-2021_01-clanokW.jpg |2021-07-07T10:00:00Z |Nová spolonos Bugatti-Rimac vzniká pod taktovkou Porsche. Koncern VW sa tak svojho klenotu nevzdá. Situácia okolo Bugatti bola dlho nejasná. Najprv sa hovorilo o jeho predaji chorvátskej spolonosti … [+2143 chars] |