

{"id":3919,"date":"2016-02-10T12:11:02","date_gmt":"2016-02-10T17:11:02","guid":{"rendered":"http:\/\/rud.is\/b\/?p=3919"},"modified":"2018-10-13T15:02:30","modified_gmt":"2018-10-13T20:02:30","slug":"craft-httr-calls-cleverly-with-curlconverter","status":"publish","type":"post","link":"https:\/\/rud.is\/b\/2016\/02\/10\/craft-httr-calls-cleverly-with-curlconverter\/","title":{"rendered":"Craft httr calls cleverly with curlconverter"},"content":{"rendered":"<p><strong>UPDATE<\/strong> <code>curlconverter<\/code> will now return (as the function return value) a <em>working R function<\/em>. See the <a href=\"https:\/\/github.com\/hrbrmstr\/curlconverter\">README<\/a> for examples<\/p>\n<hr\/>\n<p>When you visit a site like the <a href=\"http:\/\/graphics.latimes.com\/election-2016-new-hampshire-results\/\">LA Times&#8217; NH Primary Live Results site<\/a> and wish you had the data that they used to make the tables &amp; visualizations on the site:<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3921\" data-permalink=\"https:\/\/rud.is\/b\/2016\/02\/10\/craft-httr-calls-cleverly-with-curlconverter\/primary\/\" data-orig-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/02\/primary.png?fit=2560%2C1600&amp;ssl=1\" data-orig-size=\"2560,1600\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"primary\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/02\/primary.png?fit=510%2C319&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/02\/primary.png?resize=510%2C319&#038;ssl=1\" alt=\"primary\" width=\"510\" height=\"319\" class=\"alignright size-full wp-image-3921\" \/><\/p>\n<p>Sometimes it&#8217;s as simple as opening up your browsers &#8220;Developer Tools&#8221; console and looking for XHR (XML HTTP Requests) calls:<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3922\" data-permalink=\"https:\/\/rud.is\/b\/2016\/02\/10\/craft-httr-calls-cleverly-with-curlconverter\/xhr\/\" data-orig-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/02\/XHR.png?fit=2558%2C1576&amp;ssl=1\" data-orig-size=\"2558,1576\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"XHR\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/02\/XHR.png?fit=510%2C314&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/02\/XHR.png?resize=510%2C314&#038;ssl=1\" alt=\"XHR\" width=\"510\" height=\"314\" class=\"alignright size-full wp-image-3922\" \/><\/p>\n<p>You can actually see a preview of those requests (usually JSON):<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3923\" data-permalink=\"https:\/\/rud.is\/b\/2016\/02\/10\/craft-httr-calls-cleverly-with-curlconverter\/developer_tools_-_http___graphics_latimes_com_election-2016-new-hampshire-results_\/\" data-orig-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/02\/Developer_Tools_-_http___graphics_latimes_com_election-2016-new-hampshire-results_.png?fit=1502%2C832&amp;ssl=1\" data-orig-size=\"1502,832\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Developer_Tools_-_http___graphics_latimes_com_election-2016-new-hampshire-results_\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/02\/Developer_Tools_-_http___graphics_latimes_com_election-2016-new-hampshire-results_.png?fit=510%2C283&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/02\/Developer_Tools_-_http___graphics_latimes_com_election-2016-new-hampshire-results_.png?resize=510%2C283&#038;ssl=1\" alt=\"Developer_Tools_-_http___graphics_latimes_com_election-2016-new-hampshire-results_\" width=\"510\" height=\"283\" class=\"alignright size-full wp-image-3923\" \/><\/p>\n<p>While you <em>could<\/em> go through all the headers and cookies and transcribe them into <code>httr::GET<\/code> or <code>httr::POST<\/code> requests, that&#8217;s tedious, especially when most browsers present an option to <em>&#8220;Copy as cURL&#8221;<\/em>. cURL is a command-line tool (with a corresponding systems programming library) that you can use to grab data from URIs. The <code>RCurl<\/code> and <code>curl<\/code> packages in R are built with the underlying library. The cURL command line captures all of the information necessary to replicate the request the browser made for a resource. The cURL command line for the URL that gets the Republican data is:<\/p>\n<pre lang=\"bash\">curl 'http:\/\/graphics.latimes.com\/election-2016-31146-feed.json' \n  -H 'Pragma: no-cache' \n  -H 'DNT: 1' \n  -H 'Accept-Encoding: gzip, deflate, sdch'\n  -H 'X-Requested-With: XMLHttpRequest' \n  -H 'Accept-Language: en-US,en;q=0.8' \n  -H 'User-Agent: Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/49.0.2623.39 Safari\/537.36' \n  -H 'Accept: *\/*' \n  -H 'Cache-Control: no-cache' \n  -H 'If-None-Match: \"7b341d7181cbb9b72f483ae28e464dd7\"' \n  -H 'Cookie: s_fid=79D97B8B22CA721F-2DD12ACE392FF3B2; s_cc=true' \n  -H 'Connection: keep-alive' \n  -H 'If-Modified-Since: Wed, 10 Feb 2016 16:40:15 GMT'\n  -H 'Referer: http:\/\/graphics.latimes.com\/election-2016-new-hampshire-results\/' \n  --compressed<\/pre>\n<p>While that&#8217;s easier than manual copy\/paste transcription, these requests are uniform enough that there Has To Be A Better Way. And, now there is, with <a href=\"http:\/\/github.com\/hrbrmstr\/curlconverter\"><code>curlconverter<\/code><\/a>.<\/p>\n<p>The <code>curlconverter<\/code> package has (for the moment) two main functions:<\/p>\n<ul>\n<li><code>straighten()<\/code> : which returns a <code>list<\/code> with all of the necessary parts to craft an <code>httr<\/code> <code>POST<\/code> or <code>GET<\/code> call<\/li>\n<li><code>make_req()<\/code> : which actually _returns a working <code>httr<\/code> call, pre-filled with all of the necessary information.<\/li>\n<\/ul>\n<p>By default, either function reads from the clipboard (envision the workflow where you do the &#8220;Copy as cURL&#8221; then switch to R and type <code>make_req()<\/code> or <code>req_params &lt;- straighten()<\/code>), but they can take in a vector of cURL command lines, too (NOTE: <code>make_req()<\/code> is currently limited to one while <code>straighten()<\/code> can handle as many as you want).<\/p>\n<p>Let&#8217;s show what happens using election results cURL command line:<\/p>\n<pre lang=\"rsplus\">REP <- \"curl 'http:\/\/graphics.latimes.com\/election-2016-31146-feed.json' -H 'Pragma: no-cache' -H 'DNT: 1' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'X-Requested-With: XMLHttpRequest' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/49.0.2623.39 Safari\/537.36' -H 'Accept: *\/*' -H 'Cache-Control: no-cache'  -H 'Cookie: s_fid=79D97B8B22CA721F-2DD12ACE392FF3B2; s_cc=true' -H 'Connection: keep-alive' -H 'If-Modified-Since: Wed, 10 Feb 2016 16:40:15 GMT' -H 'Referer: http:\/\/graphics.latimes.com\/election-2016-new-hampshire-results\/' --compressed\"\n\nresp <- curlconverter::straighten(REP)\njsonlite::toJSON(resp, pretty=TRUE)\n\n    ## [\n    ##   {\n    ##     \"url\": [\"http:\/\/graphics.latimes.com\/election-2016-31146-feed.json\"],\n    ##     \"method\": [\"get\"],\n    ##     \"headers\": {\n    ##       \"Pragma\": [\"no-cache\"],\n    ##       \"DNT\": [\"1\"],\n    ##       \"Accept-Encoding\": [\"gzip, deflate, sdch\"],\n    ##       \"X-Requested-With\": [\"XMLHttpRequest\"],\n    ##       \"Accept-Language\": [\"en-US,en;q=0.8\"],\n    ##       \"User-Agent\": [\"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/49.0.2623.39 Safari\/537.36\"],\n    ##       \"Accept\": [\"*\/*\"],\n    ##       \"Cache-Control\": [\"no-cache\"],\n    ##       \"Connection\": [\"keep-alive\"],\n    ##       \"If-Modified-Since\": [\"Wed, 10 Feb 2016 16:40:15 GMT\"],\n    ##       \"Referer\": [\"http:\/\/graphics.latimes.com\/election-2016-new-hampshire-results\/\"]\n    ##     },\n    ##     \"cookies\": {\n    ##       \"s_fid\": [\"79D97B8B22CA721F-2DD12ACE392FF3B2\"],\n    ##       \"s_cc\": [\"true\"]\n    ##     },\n    ##     \"url_parts\": {\n    ##       \"scheme\": [\"http\"],\n    ##       \"hostname\": [\"graphics.latimes.com\"],\n    ##       \"port\": {},\n    ##       \"path\": [\"election-2016-31146-feed.json\"],\n    ##       \"query\": {},\n    ##       \"params\": {},\n    ##       \"fragment\": {},\n    ##       \"username\": {},\n    ##       \"password\": {}\n    ##     }\n    ##   }\n    ## ]<\/pre>\n<p>You can then use the items in the returned list to make a <code>GET<\/code> request manually (but still tediously).<\/p>\n<p><code>curlconverter<\/code>'s <code>make_req()<\/code> will try to do this conversion for you automagically using <code>httr<\/code>'s little used <code>VERB()<\/code> function. It's easier to show than to tell:<\/p>\n<pre lang=\"rsplus\">curlconverter::make_req(REP)<\/pre>\n<pre lang=\"rsplus\">VERB(verb = \"GET\", url = \"http:\/\/graphics.latimes.com\/election-2016-31146-feed.json\", \n     add_headers(Pragma = \"no-cache\", \n                 DNT = \"1\", `Accept-Encoding` = \"gzip, deflate, sdch\", \n                 `X-Requested-With` = \"XMLHttpRequest\", \n                 `Accept-Language` = \"en-US,en;q=0.8\", \n                 `User-Agent` = \"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/49.0.2623.39 Safari\/537.36\", \n                 Accept = \"*\/*\", \n                 `Cache-Control` = \"no-cache\", \n                 Connection = \"keep-alive\", \n                 `If-Modified-Since` = \"Wed, 10 Feb 2016 16:40:15 GMT\", \n                 Referer = \"http:\/\/graphics.latimes.com\/election-2016-new-hampshire-results\/\"))<\/pre>\n<p>You probably don't need all those headers, but you just need to delete what you don't need vs trial-and-error build by hand. Try assigning the output of that function to a variable and inspecting what's returned. I think you'll find this is a big enhancement to your workflows (if you do alot of this \"scraping without scraping\").<\/p>\n<p>You can find the package <a href=\"http:\/\/github.com\/hrbrmstr\/curlconverter\">on gitub<\/a>. It's built with <a href=\"https:\/\/cran.rstudio.com\/web\/packages\/V8\/index.html\">V8<\/a> and uses a modified version of the <a href=\"https:\/\/github.com\/NickCarneiro\/curlconverter\"><code>curlconverter<\/code><\/a> Node module by Nick Carneiro.<\/p>\n<p>It's still in beta and could use some tyre kicking. Convos in the comments, issues or feature requests in GH (pls).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>UPDATE curlconverter will now return (as the function return value) a working R function. See the README for examples When you visit a site like the LA Times&#8217; NH Primary Live Results site and wish you had the data that they used to make the tables &amp; visualizations on the site: Sometimes it&#8217;s as simple [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":""},"categories":[91,725,766],"tags":[810],"class_list":["post-3919","post","type-post","status-publish","format-standard","hentry","category-r","category-web-scraping","category-xhr","tag-post"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Craft httr calls cleverly with curlconverter - rud.is<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/rud.is\/b\/2016\/02\/10\/craft-httr-calls-cleverly-with-curlconverter\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Craft httr calls cleverly with curlconverter - rud.is\" \/>\n<meta property=\"og:description\" content=\"UPDATE curlconverter will now return (as the function return value) a working R function. See the README for examples When you visit a site like the LA Times&#8217; NH Primary Live Results site and wish you had the data that they used to make the tables &amp; visualizations on the site: Sometimes it&#8217;s as simple [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/rud.is\/b\/2016\/02\/10\/craft-httr-calls-cleverly-with-curlconverter\/\" \/>\n<meta property=\"og:site_name\" content=\"rud.is\" \/>\n<meta property=\"article:published_time\" content=\"2016-02-10T17:11:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-10-13T20:02:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/rud.is\/b\/wp-content\/uploads\/2016\/02\/primary.png\" \/>\n<meta name=\"author\" content=\"hrbrmstr\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"hrbrmstr\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/02\\\/10\\\/craft-httr-calls-cleverly-with-curlconverter\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/02\\\/10\\\/craft-httr-calls-cleverly-with-curlconverter\\\/\"},\"author\":{\"name\":\"hrbrmstr\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"headline\":\"Craft httr calls cleverly with curlconverter\",\"datePublished\":\"2016-02-10T17:11:02+00:00\",\"dateModified\":\"2018-10-13T20:02:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/02\\\/10\\\/craft-httr-calls-cleverly-with-curlconverter\\\/\"},\"wordCount\":455,\"commentCount\":9,\"publisher\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"image\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/02\\\/10\\\/craft-httr-calls-cleverly-with-curlconverter\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2016\\\/02\\\/primary.png\",\"keywords\":[\"post\"],\"articleSection\":[\"R\",\"web scraping\",\"xhr\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/02\\\/10\\\/craft-httr-calls-cleverly-with-curlconverter\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/02\\\/10\\\/craft-httr-calls-cleverly-with-curlconverter\\\/\",\"url\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/02\\\/10\\\/craft-httr-calls-cleverly-with-curlconverter\\\/\",\"name\":\"Craft httr calls cleverly with curlconverter - rud.is\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/02\\\/10\\\/craft-httr-calls-cleverly-with-curlconverter\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/02\\\/10\\\/craft-httr-calls-cleverly-with-curlconverter\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2016\\\/02\\\/primary.png\",\"datePublished\":\"2016-02-10T17:11:02+00:00\",\"dateModified\":\"2018-10-13T20:02:30+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/02\\\/10\\\/craft-httr-calls-cleverly-with-curlconverter\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/02\\\/10\\\/craft-httr-calls-cleverly-with-curlconverter\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/02\\\/10\\\/craft-httr-calls-cleverly-with-curlconverter\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2016\\\/02\\\/primary.png?fit=2560%2C1600&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2016\\\/02\\\/primary.png?fit=2560%2C1600&ssl=1\",\"width\":2560,\"height\":1600},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/02\\\/10\\\/craft-httr-calls-cleverly-with-curlconverter\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/rud.is\\\/b\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Craft httr calls cleverly with curlconverter\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#website\",\"url\":\"https:\\\/\\\/rud.is\\\/b\\\/\",\"name\":\"rud.is\",\"description\":\"&quot;In God we trust. All others must bring data&quot;\",\"publisher\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/rud.is\\\/b\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\",\"name\":\"hrbrmstr\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\",\"width\":460,\"height\":460,\"caption\":\"hrbrmstr\"},\"logo\":{\"@id\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\"},\"description\":\"Don't look at me\u2026I do what he does \u2014 just slower. #rstats avuncular \u2022 ?Resistance Fighter \u2022 Cook \u2022 Christian \u2022 [Master] Chef des Donn\u00e9es de S\u00e9curit\u00e9 @ @rapid7\",\"sameAs\":[\"http:\\\/\\\/rud.is\"],\"url\":\"https:\\\/\\\/rud.is\\\/b\\\/author\\\/hrbrmstr\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Craft httr calls cleverly with curlconverter - rud.is","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/rud.is\/b\/2016\/02\/10\/craft-httr-calls-cleverly-with-curlconverter\/","og_locale":"en_US","og_type":"article","og_title":"Craft httr calls cleverly with curlconverter - rud.is","og_description":"UPDATE curlconverter will now return (as the function return value) a working R function. See the README for examples When you visit a site like the LA Times&#8217; NH Primary Live Results site and wish you had the data that they used to make the tables &amp; visualizations on the site: Sometimes it&#8217;s as simple [&hellip;]","og_url":"https:\/\/rud.is\/b\/2016\/02\/10\/craft-httr-calls-cleverly-with-curlconverter\/","og_site_name":"rud.is","article_published_time":"2016-02-10T17:11:02+00:00","article_modified_time":"2018-10-13T20:02:30+00:00","og_image":[{"url":"https:\/\/rud.is\/b\/wp-content\/uploads\/2016\/02\/primary.png","type":"","width":"","height":""}],"author":"hrbrmstr","twitter_card":"summary_large_image","twitter_misc":{"Written by":"hrbrmstr","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/rud.is\/b\/2016\/02\/10\/craft-httr-calls-cleverly-with-curlconverter\/#article","isPartOf":{"@id":"https:\/\/rud.is\/b\/2016\/02\/10\/craft-httr-calls-cleverly-with-curlconverter\/"},"author":{"name":"hrbrmstr","@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"headline":"Craft httr calls cleverly with curlconverter","datePublished":"2016-02-10T17:11:02+00:00","dateModified":"2018-10-13T20:02:30+00:00","mainEntityOfPage":{"@id":"https:\/\/rud.is\/b\/2016\/02\/10\/craft-httr-calls-cleverly-with-curlconverter\/"},"wordCount":455,"commentCount":9,"publisher":{"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"image":{"@id":"https:\/\/rud.is\/b\/2016\/02\/10\/craft-httr-calls-cleverly-with-curlconverter\/#primaryimage"},"thumbnailUrl":"https:\/\/rud.is\/b\/wp-content\/uploads\/2016\/02\/primary.png","keywords":["post"],"articleSection":["R","web scraping","xhr"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/rud.is\/b\/2016\/02\/10\/craft-httr-calls-cleverly-with-curlconverter\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/rud.is\/b\/2016\/02\/10\/craft-httr-calls-cleverly-with-curlconverter\/","url":"https:\/\/rud.is\/b\/2016\/02\/10\/craft-httr-calls-cleverly-with-curlconverter\/","name":"Craft httr calls cleverly with curlconverter - rud.is","isPartOf":{"@id":"https:\/\/rud.is\/b\/#website"},"primaryImageOfPage":{"@id":"https:\/\/rud.is\/b\/2016\/02\/10\/craft-httr-calls-cleverly-with-curlconverter\/#primaryimage"},"image":{"@id":"https:\/\/rud.is\/b\/2016\/02\/10\/craft-httr-calls-cleverly-with-curlconverter\/#primaryimage"},"thumbnailUrl":"https:\/\/rud.is\/b\/wp-content\/uploads\/2016\/02\/primary.png","datePublished":"2016-02-10T17:11:02+00:00","dateModified":"2018-10-13T20:02:30+00:00","breadcrumb":{"@id":"https:\/\/rud.is\/b\/2016\/02\/10\/craft-httr-calls-cleverly-with-curlconverter\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/rud.is\/b\/2016\/02\/10\/craft-httr-calls-cleverly-with-curlconverter\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/rud.is\/b\/2016\/02\/10\/craft-httr-calls-cleverly-with-curlconverter\/#primaryimage","url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/02\/primary.png?fit=2560%2C1600&ssl=1","contentUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/02\/primary.png?fit=2560%2C1600&ssl=1","width":2560,"height":1600},{"@type":"BreadcrumbList","@id":"https:\/\/rud.is\/b\/2016\/02\/10\/craft-httr-calls-cleverly-with-curlconverter\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/rud.is\/b\/"},{"@type":"ListItem","position":2,"name":"Craft httr calls cleverly with curlconverter"}]},{"@type":"WebSite","@id":"https:\/\/rud.is\/b\/#website","url":"https:\/\/rud.is\/b\/","name":"rud.is","description":"&quot;In God we trust. All others must bring data&quot;","publisher":{"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/rud.is\/b\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886","name":"hrbrmstr","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","contentUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","width":460,"height":460,"caption":"hrbrmstr"},"logo":{"@id":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1"},"description":"Don't look at me\u2026I do what he does \u2014 just slower. #rstats avuncular \u2022 ?Resistance Fighter \u2022 Cook \u2022 Christian \u2022 [Master] Chef des Donn\u00e9es de S\u00e9curit\u00e9 @ @rapid7","sameAs":["http:\/\/rud.is"],"url":"https:\/\/rud.is\/b\/author\/hrbrmstr\/"}]}},"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p23idr-11d","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":5031,"url":"https:\/\/rud.is\/b\/2017\/02\/14\/spelunking-xhrs-xmlhttprequests-with-splashr\/","url_meta":{"origin":3919,"position":0},"title":"Spelunking XHRs (XMLHttpRequests) with splashr","author":"hrbrmstr","date":"2017-02-14","format":false,"excerpt":"splashr has gained some new functionality since the introductory post. First, there's a whole new Docker image for it that embeds a local web server. Why? The main request for it was to enable rendering of htmlwidgets: But if you use the new Docker image and the add_tempdir=TRUE parameter it\u2026","rel":"","context":"In &quot;R&quot;","block_context":{"text":"R","link":"https:\/\/rud.is\/b\/category\/r\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":5004,"url":"https:\/\/rud.is\/b\/2017\/02\/09\/diving-into-dynamic-website-content-with-splashr\/","url_meta":{"origin":3919,"position":1},"title":"Diving Into Dynamic Website Content with splashr","author":"hrbrmstr","date":"2017-02-09","format":false,"excerpt":"If you do enough web scraping, you'll eventually hit a wall that the trusty httr verbs (that sit beneath rvest) cannot really overcome: dynamically created content (via javascript) on a site. If the site was nice enough to use XHR requests to load the dynamic content, you can generally still\u2026","rel":"","context":"In &quot;R&quot;","block_context":{"text":"R","link":"https:\/\/rud.is\/b\/category\/r\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":5907,"url":"https:\/\/rud.is\/b\/2017\/05\/05\/scrapeover-friday-a-k-a-another-r-scraping-makeover\/","url_meta":{"origin":3919,"position":2},"title":"Scrapeover Friday \u2014 a.k.a. Another R Scraping Makeover","author":"hrbrmstr","date":"2017-05-05","format":false,"excerpt":"I caught a glimpse of a tweet by @dataandme on Friday: Using R & rvest to explore Malaysian property mkt: \"Web Scraping: The Sequel, Propwall.my\" https:\/\/t.co\/daZOOJJfPN #rstats #rvest pic.twitter.com\/u6QMhm4M3e\u2014 Mara Averick (@dataandme) May 5, 2017 Mara is \u2014 without a doubt \u2014 the best data science promoter in the Twitterverse.\u2026","rel":"","context":"In &quot;R&quot;","block_context":{"text":"R","link":"https:\/\/rud.is\/b\/category\/r\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":13849,"url":"https:\/\/rud.is\/b\/2023\/03\/21\/youre-one-javascript-function-call-away-from-using-most-webr-r-functions-in-your-webr-powered-apps-sites\/","url_meta":{"origin":3919,"position":3},"title":"You&#8217;re One JavaScript Function Call Away From Using (Most) WebR R Functions In Your WebR-Powered Apps\/Sites","author":"hrbrmstr","date":"2023-03-21","format":false,"excerpt":"After writing the initial version of a tutorial on wrapping and binding R functions on the javascript side of WebR, I had a number of other WebR projects on the TODO list. But, I stuck around noodling on the whole \"wrapping & binding\" thing, and it dawned on me that\u2026","rel":"","context":"In &quot;R&quot;","block_context":{"text":"R","link":"https:\/\/rud.is\/b\/category\/r\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4826,"url":"https:\/\/rud.is\/b\/2017\/01\/04\/the-most-important-commodity-in-2017-is-data\/","url_meta":{"origin":3919,"position":4},"title":"The Most Important Commodity in 2017 is Data","author":"hrbrmstr","date":"2017-01-04","format":false,"excerpt":"Despite being in cybersecurity nigh forever (a career that quickly turns one into a determined skeptic if you're doing your job correctly) I have often trusted various (not to be named) news sources, reports and data sources to provide honest and as-unbiased-as-possible information. The debacle in the U.S. in late\u2026","rel":"","context":"In &quot;Data Analysis&quot;","block_context":{"text":"Data Analysis","link":"https:\/\/rud.is\/b\/category\/data-analysis-2\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/01\/BN-RL751_NACM98_9U_20170103102059.jpg?fit=700%2C683&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/01\/BN-RL751_NACM98_9U_20170103102059.jpg?fit=700%2C683&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/01\/BN-RL751_NACM98_9U_20170103102059.jpg?fit=700%2C683&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/01\/BN-RL751_NACM98_9U_20170103102059.jpg?fit=700%2C683&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":6067,"url":"https:\/\/rud.is\/b\/2017\/06\/05\/r%e2%81%b6-scraping-images-to-pdfs\/","url_meta":{"origin":3919,"position":5},"title":"R\u2076 \u2014 Scraping Images To PDFs","author":"hrbrmstr","date":"2017-06-05","format":false,"excerpt":"I've been doing intermittent prep work for a follow-up to an earlier post on store closings and came across this CNN Money \"article\" on it. Said \"article\" is a deliberately obfuscated or lazily crafted series of GIF images that contain all the Radio Shack impending store closings. It's the most\u2026","rel":"","context":"In &quot;R&quot;","block_context":{"text":"R","link":"https:\/\/rud.is\/b\/category\/r\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/3919","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/comments?post=3919"}],"version-history":[{"count":0,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/3919\/revisions"}],"wp:attachment":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/media?parent=3919"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/categories?post=3919"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/tags?post=3919"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}