{"id":195213,"date":"2023-08-23T13:22:29","date_gmt":"2023-08-23T17:22:29","guid":{"rendered":"https:\/\/ibkrcampus.com\/?p=195213"},"modified":"2023-08-23T13:22:36","modified_gmt":"2023-08-23T17:22:36","slug":"how-to-download-image-files-with-robobrowser","status":"publish","type":"post","link":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/how-to-download-image-files-with-robobrowser\/","title":{"rendered":"How to Download Image Files with RoboBrowser"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In a&nbsp;<a href=\"https:\/\/theautomatic.net\/2017\/09\/19\/robobrowser-automating-online-forms\/\">previous post<\/a>, we showed how RoboBrowser can be used to fill out online forms for getting historical weather data from&nbsp;<a href=\"https:\/\/www.wunderground.com\/history\">Wunderground<\/a>. This article will talk about how to use RoboBrowser to batch download collections of image files from&nbsp;<a href=\"https:\/\/www.pexels.com\/\">Pexels<\/a>, a site which offers free downloads. If you\u2019re looking to work with images, or want to build a training set for an image classifier with Python, this post will help you do that.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the first part of the code, we\u2019ll load the RoboBrowser class from the robobrowser package, create a browser object which acts like a web browser, and navigate to the&nbsp;<a href=\"https:\/\/www.pexels.com\/\">Pexels<\/a>&nbsp;website.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># load the RoboBrowser class from robobrowser\nfrom robobrowser import RoboBrowser\n \n# define base site\nbase = \"https:\/\/www.pexels.com\/\"\n \n# create browser object, \n# which serves as an invisible web browser\nbrowser = RoboBrowser()\n \n# navigate to pexels.com\nbrowser.open(base)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you actually go to the website, you\u2019ll see there\u2019s a search box. We can identify this search form using the&nbsp;<strong>get_form<\/strong>&nbsp;method. Once we have this form, we can check what fields it contains by printing the&nbsp;<strong>fields<\/strong>&nbsp;attribute.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">form = browser.get_form()\n \nprint(form.fields)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Printing the fields shows us that the search field name associated with the search box is \u201cs\u201d. This means that if we want to programmatically type something into the search box, we need to set that field\u2019s value to our search input. Thus, if we want to search for pictures of \u201cwater\u201d, we can do it like so:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># set search input to water\nform[\"s\"] = \"water\"\n \n# submit form\nbrowser.submit_form(form)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">After we\u2019ve submitted the search box, we can see what our current URL is by checking the&nbsp;<strong>url<\/strong>&nbsp;attribute.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">print(browser.url)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Next, let\u2019s examine the links on the page of results.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># get links on page\nlinks = browser.get_links()\n \n# get the URL of each page by scraping the href attribute\n# of each link\nurls = [link.get(\"href\") for link in links]\n \n# filter out any URLs from links without href attributes\n# these appear as Python's special NoneType\nurls = [url for url in urls if url is not None]<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now that we have the URLs on the page, let\u2019s filter them to only the ones showing the search result images on the page. We can do this by looking for where \u201c\/photo\/\u201d appears in each URL.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># filter to what we need -- photo URLs\nphotos = [url for url in urls if '\/photo\/' in url]\n \n# get photo link objects\nphoto_links = [link for link in links if link.get(\"href\") in photos]<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For our first example, let\u2019s click on the first photo link (0th Python-indexed link) using the&nbsp;<strong>follow_link<\/strong>&nbsp;method.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">browser.follow_link(photo_links[0])<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Next, we want to find the link on the screen that says \u201cFree Download.\u201d This can be done using the&nbsp;<strong>get_link<\/strong>&nbsp;method of browser. All we need to do is to pass whatever text on the link we\u2019re looking for i.e. \u201cFree Download\u201d in this case.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># get the download link\ndownload_link = browser.get_link(\"Free Download\")\n \n# hit the download link\nbrowser.open(download_link.get(\"href\"))<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Once we\u2019ve hit the link, we can write the file data to disk, using&nbsp;<strong>browser.response.content<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># get file name of picture from URL\nfile_name = photo[0].split(\"-\")[-2]\n \nwith open(file_name + '.jpeg', \"wb\") as image_file:\n    image_file.write(browser.response.content)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Suppose we wanted to download all of the images on the results page. We can tweak our code above like this:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># download every image on the first screen of results:\nfor url in photos:\n     \n    full_url = \"https:\/\/pexels.com\" + url\n \n    try:    \n        browser.open(full_url)\n     \n        download_link = browser.get_link(\"Free Download\")\n         \n        browser.open(download_link.get(\"href\"))\n         \n        file_name = url.split(\"\/\")[-2] + '.jpg'\n        with open(file_name, \"wb\") as image_file:\n            image_file.write(browser.response.content)   \n             \n    except Exception:\n         \n        pass<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Instead of just downloading the images for one particular search query, we can modify our code above to create a generalized function, which will download the search result images associated with whatever input we choose.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Generalized function<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">def download_search_results(search_query):\n     \n    browser.open(base)\n     \n    form = browser.get_form()\n       \n    form['s'] = search_query\n     \n    browser.submit_form(form)\n \n    links = browser.get_links()\n    urls = [link.get(\"href\") for link in links]\n    urls = [url for url in urls if url is not None]\n     \n    # filter to what we need -- photos\n    photos = [url for url in urls if '\/photo\/' in url]\n     \n    for url in photos:\n         \n        full_url = \"https:\/\/pexels.com\" + url\n     \n        try:    \n            browser.open(full_url)\n         \n            download_link = browser.get_link(\"Free Download\")\n             \n            browser.open(download_link.get(\"href\"))\n             \n            file_name = url.split(\"\/\")[-2] + '.jpg'\n            with open(file_name, \"wb\") as image_file:\n                image_file.write(browser.response.content)   \n                 \n        except Exception:\n             \n            pass<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then, we can call our function like this:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">download_search_results(\"water\")\n \ndownload_search_results(\"river\")\n \ndownload_search_results(\"lake\")<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">As mentioned previously, using RoboBrowser to download images from&nbsp;<a href=\"https:\/\/www.pexels.com\/\">Pexels<\/a>&nbsp;can also be really useful if you\u2019re looking to build your own image classifier and you need to collect images for a training set. For instance, if you want to build a classifier that predicts if an image contains a dog or not, you could scrape&nbsp;<a href=\"https:\/\/www.pexels.com\/\">Pexels<\/a>&nbsp;with our function above to get training images, like this:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">download_search_results(\"dog\")<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">So far our code has one main drawback \u2014 our function currently just pull\u2019s one page\u2019s worth of results. If you want to pull additional pages, we need to adjust the search URL. For instance, to get the second page of dog images, we need to hit&nbsp;<a href=\"https:\/\/www.pexels.com\/search\/dog\/?page=2\">https:\/\/www.pexels.com\/search\/dog\/?page=2<\/a>. If we want to pull additional pages, we need to change our function\u2019s code to hit these sequential URLS \u2014 ?page=2, ?page=3, \u2026until either we have all of the images downloaded, or we\u2019ve reached a certain page limit. Given that there might be thousands of images associated with a particular search query, you might want to set a limit to how many search results pages you hit.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Generalized function \u2013 download all page results up to a limit<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">def download_all_search_results(search_query, MAX_PAGE_INDEX = 30):\n     \n    browser.open(base)\n     \n    form = browser.get_form()\n       \n    form['s'] = search_query\n     \n    browser.submit_form(form)\n     \n    search_url = browser.url # new URL\n     \n    # create page index counter\n    page_index = 1\n \n    # define temporary holder for the photo links\n    photos = [None]\n \n    # set limit on page index\n    # loop will break before MAX_PAGE_INDEX if there are less page results\n    while photos != [] and page_index &lt;= MAX_PAGE_INDEX:\n         \n        browser.open(search_url + \"?page=\" + str(page_index))\n        \n        links = browser.get_links()\n        urls = [link.get(\"href\") for link in links]\n        urls = [url for url in urls if url is not None]\n         \n        # filter to what we need -- photos\n        photos = [url for url in urls if '\/photo\/' in url]\n         \n        if photos == []:\n            break\n         \n         \n        for url in photos:\n             \n            full_url = \"https:\/\/pexels.com\" + url\n         \n            try:    \n                browser.open(full_url)\n             \n                download_link = browser.get_link(\"Free Download\")\n                 \n                browser.open(download_link.get(\"href\"), stream = True)\n                 \n                file_name = url.split(\"\/\")[-2] + '.jpg'\n                with open(file_name, \"wb\") as image_file:\n                    image_file.write(browser.response.content)   \n                     \n            except Exception:\n                 \n                pass\n \n        print(\"page index ==> \" + str(page_index))\n        page_index += 1<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now we can call our function similar to above:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># download all the images from the first 30 pages\n# of results for 'dog'\ndownload_all_search_results(\"dog\")\n \n# Or -- just get first 10 pages of results\ndownload_all_search_results(\"dog\", 10)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You could also limit the number of downloads directly i.e. set a limit of 100, 200, 300, or \u201cX\u201d number of images you want to download.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Originally posted on the <a href=\"https:\/\/theautomatic.net\/2018\/07\/16\/how-to-download-image-files-with-robobrowser\/\">TheAutomatic.net<\/a> blog.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the first part of the code, we\u2019ll load the RoboBrowser class from the robobrowser package, create a browser object which acts like a web browser, and navigate to the Pexels website.<\/p>\n","protected":false},"author":388,"featured_media":44292,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[339,343,349,338,342],"tags":[806,14988],"contributors-categories":[13695],"class_list":["post-195213","post","type-post","status-publish","format-standard","has-post-thumbnail","category-data-science","category-programing-languages","category-python-development","category-ibkr-quant-news","category-r-development","tag-data-science","tag-robobrowser","contributors-categories-theautomatic-net"],"pp_statuses_selecting_workflow":false,"pp_workflow_action":"current","pp_status_selection":"publish","acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.9 (Yoast SEO v27.8) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Download Image Files with RoboBrowser | IBKR Quant<\/title>\n<meta name=\"description\" content=\"In the first part of the code, we\u2019ll load the RoboBrowser class from the robobrowser package, create a browser object which acts like a web browser,...\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.interactivebrokers.com\/campus\/wp-json\/wp\/v2\/posts\/195213\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Download Image Files with RoboBrowser | IBKR Campus US\" \/>\n<meta property=\"og:description\" content=\"In the first part of the code, we\u2019ll load the RoboBrowser class from the robobrowser package, create a browser object which acts like a web browser, and navigate to the Pexels website.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/how-to-download-image-files-with-robobrowser\/\" \/>\n<meta property=\"og:site_name\" content=\"IBKR Campus US\" \/>\n<meta property=\"article:published_time\" content=\"2023-08-23T17:22:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-23T17:22:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2020\/05\/target-download.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"900\" \/>\n\t<meta property=\"og:image:height\" content=\"550\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Andrew Treadway\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Andrew Treadway\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\n\t    \"@context\": \"https:\\\/\\\/schema.org\",\n\t    \"@graph\": [\n\t        {\n\t            \"@type\": \"NewsArticle\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/how-to-download-image-files-with-robobrowser\\\/#article\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/how-to-download-image-files-with-robobrowser\\\/\"\n\t            },\n\t            \"author\": {\n\t                \"name\": \"Andrew Treadway\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/d4018570a16fb867f1c08412fc9c64bc\"\n\t            },\n\t            \"headline\": \"How to Download Image Files with RoboBrowser\",\n\t            \"datePublished\": \"2023-08-23T17:22:29+00:00\",\n\t            \"dateModified\": \"2023-08-23T17:22:36+00:00\",\n\t            \"mainEntityOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/how-to-download-image-files-with-robobrowser\\\/\"\n\t            },\n\t            \"wordCount\": 701,\n\t            \"commentCount\": 0,\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/how-to-download-image-files-with-robobrowser\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2020\\\/05\\\/target-download.jpg\",\n\t            \"keywords\": [\n\t                \"Data Science\",\n\t                \"RoboBrowser\"\n\t            ],\n\t            \"articleSection\": [\n\t                \"Data Science\",\n\t                \"Programming Languages\",\n\t                \"Python Development\",\n\t                \"Quant\",\n\t                \"R Development\"\n\t            ],\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"CommentAction\",\n\t                    \"name\": \"Comment\",\n\t                    \"target\": [\n\t                        \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/how-to-download-image-files-with-robobrowser\\\/#respond\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"WebPage\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/how-to-download-image-files-with-robobrowser\\\/\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/how-to-download-image-files-with-robobrowser\\\/\",\n\t            \"name\": \"How to Download Image Files with RoboBrowser | IBKR Campus US\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\"\n\t            },\n\t            \"primaryImageOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/how-to-download-image-files-with-robobrowser\\\/#primaryimage\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/how-to-download-image-files-with-robobrowser\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2020\\\/05\\\/target-download.jpg\",\n\t            \"datePublished\": \"2023-08-23T17:22:29+00:00\",\n\t            \"dateModified\": \"2023-08-23T17:22:36+00:00\",\n\t            \"description\": \"In the first part of the code, we\u2019ll load the RoboBrowser class from the robobrowser package, create a browser object which acts like a web browser, and navigate to the Pexels website.\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"ReadAction\",\n\t                    \"target\": [\n\t                        \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/how-to-download-image-files-with-robobrowser\\\/\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"ImageObject\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/how-to-download-image-files-with-robobrowser\\\/#primaryimage\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2020\\\/05\\\/target-download.jpg\",\n\t            \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2020\\\/05\\\/target-download.jpg\",\n\t            \"width\": 900,\n\t            \"height\": 550,\n\t            \"caption\": \"Quant Download\"\n\t        },\n\t        {\n\t            \"@type\": \"WebSite\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/\",\n\t            \"name\": \"IBKR Campus US\",\n\t            \"description\": \"Financial Education from Interactive Brokers\",\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"SearchAction\",\n\t                    \"target\": {\n\t                        \"@type\": \"EntryPoint\",\n\t                        \"urlTemplate\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/?s={search_term_string}\"\n\t                    },\n\t                    \"query-input\": {\n\t                        \"@type\": \"PropertyValueSpecification\",\n\t                        \"valueRequired\": true,\n\t                        \"valueName\": \"search_term_string\"\n\t                    }\n\t                }\n\t            ],\n\t            \"inLanguage\": \"en-US\"\n\t        },\n\t        {\n\t            \"@type\": \"Organization\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\",\n\t            \"name\": \"Interactive Brokers\",\n\t            \"alternateName\": \"IBKR\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/\",\n\t            \"logo\": {\n\t                \"@type\": \"ImageObject\",\n\t                \"inLanguage\": \"en-US\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/logo\\\/image\\\/\",\n\t                \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/ibkr-campus-logo.jpg\",\n\t                \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/ibkr-campus-logo.jpg\",\n\t                \"width\": 669,\n\t                \"height\": 669,\n\t                \"caption\": \"Interactive Brokers\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/logo\\\/image\\\/\"\n\t            },\n\t            \"publishingPrinciples\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/about-ibkr-campus\\\/\",\n\t            \"ethicsPolicy\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/cyber-security-notice\\\/\"\n\t        },\n\t        {\n\t            \"@type\": \"Person\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/d4018570a16fb867f1c08412fc9c64bc\",\n\t            \"name\": \"Andrew Treadway\",\n\t            \"description\": \"Andrew Treadway currently works as a Senior Data Scientist, and has experience doing analytics, software automation, and ETL. He completed a master\u2019s degree in computer science \\\/ machine learning, and an undergraduate degree in pure mathematics. Connect with him on LinkedIn: https:\\\/\\\/www.linkedin.com\\\/in\\\/andrew-treadway-a3b19b103\\\/In addition to TheAutomatic.net blog, he also teaches in-person courses on Python and R through my NYC meetup: more details.\",\n\t            \"sameAs\": [\n\t                \"https:\\\/\\\/theautomatic.net\\\/about-me\\\/\"\n\t            ],\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/author\\\/andrewtreadway\\\/\"\n\t        }\n\t    ]\n\t}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Download Image Files with RoboBrowser | IBKR Quant","description":"In the first part of the code, we\u2019ll load the RoboBrowser class from the robobrowser package, create a browser object which acts like a web browser,...","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:\/\/www.interactivebrokers.com\/campus\/wp-json\/wp\/v2\/posts\/195213\/","og_locale":"en_US","og_type":"article","og_title":"How to Download Image Files with RoboBrowser | IBKR Campus US","og_description":"In the first part of the code, we\u2019ll load the RoboBrowser class from the robobrowser package, create a browser object which acts like a web browser, and navigate to the Pexels website.","og_url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/how-to-download-image-files-with-robobrowser\/","og_site_name":"IBKR Campus US","article_published_time":"2023-08-23T17:22:29+00:00","article_modified_time":"2023-08-23T17:22:36+00:00","og_image":[{"width":900,"height":550,"url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2020\/05\/target-download.jpg","type":"image\/jpeg"}],"author":"Andrew Treadway","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Andrew Treadway","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/how-to-download-image-files-with-robobrowser\/#article","isPartOf":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/how-to-download-image-files-with-robobrowser\/"},"author":{"name":"Andrew Treadway","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/d4018570a16fb867f1c08412fc9c64bc"},"headline":"How to Download Image Files with RoboBrowser","datePublished":"2023-08-23T17:22:29+00:00","dateModified":"2023-08-23T17:22:36+00:00","mainEntityOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/how-to-download-image-files-with-robobrowser\/"},"wordCount":701,"commentCount":0,"publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/how-to-download-image-files-with-robobrowser\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2020\/05\/target-download.jpg","keywords":["Data Science","RoboBrowser"],"articleSection":["Data Science","Programming Languages","Python Development","Quant","R Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/how-to-download-image-files-with-robobrowser\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/how-to-download-image-files-with-robobrowser\/","url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/how-to-download-image-files-with-robobrowser\/","name":"How to Download Image Files with RoboBrowser | IBKR Campus US","isPartOf":{"@id":"https:\/\/ibkrcampus.com\/campus\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/how-to-download-image-files-with-robobrowser\/#primaryimage"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/how-to-download-image-files-with-robobrowser\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2020\/05\/target-download.jpg","datePublished":"2023-08-23T17:22:29+00:00","dateModified":"2023-08-23T17:22:36+00:00","description":"In the first part of the code, we\u2019ll load the RoboBrowser class from the robobrowser package, create a browser object which acts like a web browser, and navigate to the Pexels website.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/how-to-download-image-files-with-robobrowser\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/how-to-download-image-files-with-robobrowser\/#primaryimage","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2020\/05\/target-download.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2020\/05\/target-download.jpg","width":900,"height":550,"caption":"Quant Download"},{"@type":"WebSite","@id":"https:\/\/ibkrcampus.com\/campus\/#website","url":"https:\/\/ibkrcampus.com\/campus\/","name":"IBKR Campus US","description":"Financial Education from Interactive Brokers","publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ibkrcampus.com\/campus\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/ibkrcampus.com\/campus\/#organization","name":"Interactive Brokers","alternateName":"IBKR","url":"https:\/\/ibkrcampus.com\/campus\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/logo\/image\/","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/05\/ibkr-campus-logo.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/05\/ibkr-campus-logo.jpg","width":669,"height":669,"caption":"Interactive Brokers"},"image":{"@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/logo\/image\/"},"publishingPrinciples":"https:\/\/www.interactivebrokers.com\/campus\/about-ibkr-campus\/","ethicsPolicy":"https:\/\/www.interactivebrokers.com\/campus\/cyber-security-notice\/"},{"@type":"Person","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/d4018570a16fb867f1c08412fc9c64bc","name":"Andrew Treadway","description":"Andrew Treadway currently works as a Senior Data Scientist, and has experience doing analytics, software automation, and ETL. He completed a master\u2019s degree in computer science \/ machine learning, and an undergraduate degree in pure mathematics. Connect with him on LinkedIn: https:\/\/www.linkedin.com\/in\/andrew-treadway-a3b19b103\/In addition to TheAutomatic.net blog, he also teaches in-person courses on Python and R through my NYC meetup: more details.","sameAs":["https:\/\/theautomatic.net\/about-me\/"],"url":"https:\/\/www.interactivebrokers.com\/campus\/author\/andrewtreadway\/"}]}},"jetpack_featured_media_url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2020\/05\/target-download.jpg","_links":{"self":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/195213","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/users\/388"}],"replies":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/comments?post=195213"}],"version-history":[{"count":0,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/195213\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media\/44292"}],"wp:attachment":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media?parent=195213"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/categories?post=195213"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/tags?post=195213"},{"taxonomy":"contributors-categories","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/contributors-categories?post=195213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}