Could not resolve host error in R (Have access to website in browser)

Hi, I am trying to download google trends data using gtrendsR package in RStudio. The problem is the code works in my personal computer and when i try to run the same in company's laptop it is throwing an error.

I have access to the google trends website on my laptop. I can open it in browser and download the data as well but the problem comes when i try to do the same using R. I have searched different threads on this platform, github and Stackexchange but couldn't get past this.

Just to inform, I cant access websites when i ping them from Command prompt as well. Are there any proxy settings that I should apply.

It would be of immense help if someone can guide me on how to resolve this issue or give some direction on how to go about it.

Following is the code

#Defining parameters for gtrends function
keyword_list <- c("quarantine", "unemployment", "business closures", "restaurant")
country <- "US"
channel <- "web"
time <- "all" #Time span between two dates can be given as the following (ex.: "2020-01-01 2020-05-01")

#Downloading data for a single keyword google trends
#us_quarantine <- gtrends(keyword = "quarantine", geo = country, time = time)

# The for loop downloads the data for every single keyword in keyword list
resultslist <- list() 

keywords <- keyword_list[1]
for (keywords in keyword_list) {
    trends = gtrends(keywords, gprop = channel, geo = country, time = time)
    resultslist[[keywords]] <- trends$interest_over_time

# Merge all the data into a dataframe
output <-"rbind", resultslist)) 

Following is the error I am getting

Error in curl::curl_fetch_memory(cookie_url, handle = cookie_handler) : 
  Could not resolve host:
Calls: gtrends -> get_widget -> get_api_cookies -> <Anonymous>

Enter a frame number, or 0 to exit   

1: gtrends(keywords, gprop = channel, geo = country, time = time)
2: get_widget(comparison_item, category, gprop, hl, cookie_url, tz)
3: get_api_cookies(cookie_url)
4: curl::curl_fetch_memory(cookie_url, handle = cookie_handler)


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.