You can install the development version of chatgptscrapeR
from
GitHub with:
# install.packages("devtools")
devtools::install_github("sonsoleslp/chatgptscrapeR")
Load the library
library("chatgptscrapeR")
library("dplyr")
library("tidyr")
Scrape one conversation
# URL of the ChatGPT conversation
url1 <- "https://chatgpt.com/share/c7a912da-5dd3-4e46-9fd7-d777006068ff"
url2 <- "https://chatgpt.com/share/c302f7d3-9d89-4d93-ab89-68c0bfd0b667"
# Scrape the conversation
conversation <- scrape_chatgpt(url1)
select(conversation, order, message.author.role, message.content.parts)
order | message.author.role | message.content.parts |
---|---|---|
— | — | |
— | system | |
1 | user | Why is R better than Python? |
2 | assistant | Choosing between R and Python often depends on the specific needs and context of a project, as both have their strengths and weaknesses. Here are some reasons why R might be considered better than Python for certain tasks:
While Python is a versatile general-purpose programming language with a strong ecosystem for data science, machine learning, and web development, R's strength lies in its specialized focus on statistical analysis and data visualization. The choice between R and Python should be based on the specific needs of your project and your personal or team's expertise and preferences. For tasks heavily reliant on statistical methods and complex data visualizations, R often proves to be more efficient and effective. |
Scrape an array of conversations
urls <- c(url1, url2)
# Scrape the conversations
conversation <- scrape_chatgpt(urls)
select(conversation, order, title, message.author.role, message.content.parts)
order | title | message.author.role | message.content.parts |
---|---|---|---|
— | R vs Python Benefits | — | |
— | R vs Python Benefits | system | |
1 | R vs Python Benefits | user | Why is R better than Python? |
2 | R vs Python Benefits | assistant | Choosing between R and Python often depends on the specific needs and context of a project, as both have their strengths and weaknesses. Here are some reasons why R might be considered better than Python for certain tasks:
While Python is a versatile general-purpose programming language with a strong ecosystem for data science, machine learning, and web development, R's strength lies in its specialized focus on statistical analysis and data visualization. The choice between R and Python should be based on the specific needs of your project and your personal or team's expertise and preferences. For tasks heavily reliant on statistical methods and complex data visualizations, R often proves to be more efficient and effective. |
— | Why Spain is Great | — | |
— | Why Spain is Great | system | |
1 | Why Spain is Great | user | Why is Spain the best country in Europe? |
2 | Why Spain is Great | assistant | Spain is often considered one of the best countries in Europe for various reasons, reflecting its rich culture, history, natural beauty, and quality of life. Here are several factors that contribute to Spain's appeal:
Spain boasts a diverse cultural heritage influenced by various civilizations, including the Romans, Moors, and Visigoths. Cities like Barcelona, Madrid, Seville, and Granada offer architectural marvels such as the Sagrada Familia, Alhambra, and the Royal Palace. Spain is famous for its lively festivals, including La Tomatina, Running of the Bulls in Pamplona, Las Fallas in Valencia, and Semana Santa (Holy Week) processions. These events showcase the country's festive spirit and traditions. Spanish cuisine is renowned worldwide. Tapas, paella, jamón ibérico, and a variety of regional dishes offer a culinary journey. The Mediterranean diet, prevalent in Spain, is also considered one of the healthiest diets globally. Spain's geography is incredibly diverse, featuring stunning beaches along the Costa del Sol and Costa Brava, mountainous regions like the Pyrenees and Sierra Nevada, and picturesque countryside in regions like Andalusia and Castilla-La Mancha. Spain enjoys a Mediterranean climate with warm summers and mild winters, especially along the coastal areas. The Canary Islands offer a subtropical climate, making Spain a year-round destination. Spain ranks high in quality of life, with excellent healthcare, a relaxed lifestyle, and a strong sense of community. The cost of living in Spain is relatively affordable compared to other Western European countries. Spain has a rich artistic and literary heritage, producing world-renowned artists like Pablo Picasso, Salvador Dalí, and Francisco Goya, as well as literary figures like Miguel de Cervantes, the author of "Don Quixote." Spain is passionate about sports, particularly football (soccer). The country is home to some of the most famous football clubs in the world, such as FC Barcelona and Real Madrid. Spain has also excelled in other sports, including tennis, basketball, and motor racing. Spaniards are known for their hospitality and friendliness. The strong emphasis on family and social connections makes visitors feel welcome and integrated into the local culture. Spain has played a pivotal role in world history, from the era of the Spanish Empire, which influenced large parts of the world, to its significant contributions to art, science, and exploration. These factors, among others, contribute to Spain's reputation as one of the best countries in Europe. Its combination of cultural richness, natural beauty, and quality of life offers something for everyone. |
3 | Why Spain is Great | user | Which city in Spain is the best? |
4 | Why Spain is Great | assistant | The "best" city in Spain can be subjective, as it depends on personal preferences and what one is looking for in a city. However, a few cities stand out for their unique offerings, cultural significance, and overall appeal:
Ultimately, the best city in Spain depends on what you're looking for:
Each city offers a unique experience and highlights different aspects of Spain's diverse culture and history. |
Scrape a dataframe containing conversation URLs
df <- data.frame(user = c("User1", "User2"),
age = c(15, 14),
gender = c("M", "F"),
url = urls)
conversation <- scrape_chatgpt(df, column = "url") |> filter(!is.na(order))
order | user | title | message.author.role | message.content.parts |
---|---|---|---|---|
1 | User1 | R vs Python Benefits | user | Why is R better than Python? |
2 | User1 | R vs Python Benefits | assistant | Choosing between R and Python often depends on the specific needs and context of a project, as both have their strengths and weaknesses. Here are some reasons why R might be considered better than Python for certain tasks:
While Python is a versatile general-purpose programming language with a strong ecosystem for data science, machine learning, and web development, R's strength lies in its specialized focus on statistical analysis and data visualization. The choice between R and Python should be based on the specific needs of your project and your personal or team's expertise and preferences. For tasks heavily reliant on statistical methods and complex data visualizations, R often proves to be more efficient and effective. |
1 | User2 | Why Spain is Great | user | Why is Spain the best country in Europe? |
2 | User2 | Why Spain is Great | assistant | Spain is often considered one of the best countries in Europe for various reasons, reflecting its rich culture, history, natural beauty, and quality of life. Here are several factors that contribute to Spain's appeal:
Spain boasts a diverse cultural heritage influenced by various civilizations, including the Romans, Moors, and Visigoths. Cities like Barcelona, Madrid, Seville, and Granada offer architectural marvels such as the Sagrada Familia, Alhambra, and the Royal Palace. Spain is famous for its lively festivals, including La Tomatina, Running of the Bulls in Pamplona, Las Fallas in Valencia, and Semana Santa (Holy Week) processions. These events showcase the country's festive spirit and traditions. Spanish cuisine is renowned worldwide. Tapas, paella, jamón ibérico, and a variety of regional dishes offer a culinary journey. The Mediterranean diet, prevalent in Spain, is also considered one of the healthiest diets globally. Spain's geography is incredibly diverse, featuring stunning beaches along the Costa del Sol and Costa Brava, mountainous regions like the Pyrenees and Sierra Nevada, and picturesque countryside in regions like Andalusia and Castilla-La Mancha. Spain enjoys a Mediterranean climate with warm summers and mild winters, especially along the coastal areas. The Canary Islands offer a subtropical climate, making Spain a year-round destination. Spain ranks high in quality of life, with excellent healthcare, a relaxed lifestyle, and a strong sense of community. The cost of living in Spain is relatively affordable compared to other Western European countries. Spain has a rich artistic and literary heritage, producing world-renowned artists like Pablo Picasso, Salvador Dalí, and Francisco Goya, as well as literary figures like Miguel de Cervantes, the author of "Don Quixote." Spain is passionate about sports, particularly football (soccer). The country is home to some of the most famous football clubs in the world, such as FC Barcelona and Real Madrid. Spain has also excelled in other sports, including tennis, basketball, and motor racing. Spaniards are known for their hospitality and friendliness. The strong emphasis on family and social connections makes visitors feel welcome and integrated into the local culture. Spain has played a pivotal role in world history, from the era of the Spanish Empire, which influenced large parts of the world, to its significant contributions to art, science, and exploration. These factors, among others, contribute to Spain's reputation as one of the best countries in Europe. Its combination of cultural richness, natural beauty, and quality of life offers something for everyone. |
3 | User2 | Why Spain is Great | user | Which city in Spain is the best? |
4 | User2 | Why Spain is Great | assistant | The "best" city in Spain can be subjective, as it depends on personal preferences and what one is looking for in a city. However, a few cities stand out for their unique offerings, cultural significance, and overall appeal:
Ultimately, the best city in Spain depends on what you're looking for:
Each city offers a unique experience and highlights different aspects of Spain's diverse culture and history. |
text_data <- conversation |>
group_by(message.author.role) |>
get_keywords(token ="words", top = 5, remove_stopwords = T)
conversation |> get_keywords(token ="words", top = 5, remove_stopwords = T)
#> word n
#> 1 spain 16
#> 2 statistical 14
#> 3 city 13
#> 4 data 13
#> 5 r 13