@@ -45,15 +45,35 @@ download_db <- function(url,
45
45
cli :: cli_alert_info(" Downloading data from {.url {url}}." )
46
46
}
47
47
48
+ dat_file <- tempfile(fileext = file_ext )
49
+
50
+ if (isTRUE(check_need_libcurl_condathis())) {
51
+ condathis_downgrade_libcurl()
52
+
53
+ url_to_use <-
54
+ paste0(url ,
55
+ " ?" ,
56
+ paste(names(url_query_param ),
57
+ url_query_param ,
58
+ sep = " =" ,
59
+ collapse = " &" ))
60
+
61
+ req <- condathis :: run(" curl" , " -o" , dat_file , url_to_use ,
62
+ env_name = " openssl-linux-env" ,
63
+ verbose = FALSE )
64
+
65
+
66
+ }
67
+
68
+
69
+
48
70
req <- httr2 :: request(url ) | >
49
71
httr2 :: req_url_query(
50
72
!!! url_query_param ,
51
73
multi = " explore"
52
74
) | >
53
75
httr2 :: req_perform()
54
76
55
- dat_file <- tempfile(fileext = file_ext )
56
-
57
77
req | >
58
78
httr2 :: resp_body_raw() | >
59
79
writeBin(dat_file )
@@ -71,27 +91,58 @@ download_db <- function(url,
71
91
out_cl
72
92
}
73
93
94
+ # curl_res <- condathis::run("curl",
95
+ # paste0(base_url, query_string, collapse = ""),
96
+ # env_name = "openssl-linux-env", verbose = FALSE
97
+ # )
98
+
99
+ # # Need to downgrade libcurl?
100
+ # if (isTRUE(check_need_libcurl_condathis())) {
101
+ # condathis_downgrade_libcurl()
102
+ # extr_iris_to_use <- extr_iris_openssl_
103
+ # } else {
104
+ # extr_iris_to_use <- extr_iris_
105
+ # }
106
+ # curl -o prova.html 'https://cfpub.epa.gov/ncea/pprtv/atoz.cfm?excel=yes'
107
+ # curl 'https://cfpub.epa.gov/ncea/pprtv/atoz.cfm?excel=yes'
108
+ # list(excel = "yes"),
109
+
110
+ # curl_command <- paste("curl -o",
111
+ # file_name,
112
+ # paste0(
113
+ # url,
114
+ # "?",
115
+ # paste(names(url_query_param),
116
+ # url_query_param,
117
+ # sep = "=",
118
+ # collapse = "&")))
74
119
75
120
# ' Search and Match Data
76
121
# '
77
- # ' This function searches for matches in a dataframe based on a given list of ids
78
- # ' and search type, then combines the results into a single dataframe, making sure
79
- # ' that NA rows are added for any missing ids. The column `query` is a the end of
80
- # ' the dataframe.
122
+ # ' This function searches for matches in a dataframe based on a given list of
123
+ # ' ids and search type, then combines the results into a single dataframe,
124
+ # ' making sure that NA rows are added for any missing ids. The column
125
+ # ' `query` is a the end of the dataframe.
81
126
# '
82
127
# ' @param dat The dataframe to be searched.
83
128
# ' @param ids A vector of ids to search for.
84
129
# ' @param search_type The type of search: "casrn" or "name".
85
- # ' @param col_names Column names to be used when creating a new dataframe in case of no matches.
86
- # ' @param chemical_col The name of the column in dat where chemical names are stored.
130
+ # ' @param col_names Column names to be used when creating a new dataframe in
131
+ # ' case of no matches.
132
+ # ' @param chemical_col The name of the column in dat where chemical names
133
+ # ' are stored.
87
134
# ' @return A dataframe with search results.
88
135
# ' @keywords internal
89
136
# '
90
137
# ' @details This function is used in `extr_pprtv` and `extr_monograph`.
91
138
# '
92
139
# ' @seealso
93
140
# ' \code{\link{extr_pprtv}}, \code{\link{extr_monograph}}
94
- search_and_match <- function (dat , ids , search_type , col_names , chemical_col = " chemical" ) {
141
+ search_and_match <- function (dat ,
142
+ ids ,
143
+ search_type ,
144
+ col_names ,
145
+ chemical_col = " chemical" ) {
95
146
results <- lapply(ids , function (id ) {
96
147
if (search_type == " casrn" ) {
97
148
match <- dat [dat $ casrn == id , ]
0 commit comments