<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Romik Kelesh on Medium]]></title>
        <description><![CDATA[Stories by Romik Kelesh on Medium]]></description>
        <link>https://medium.com/@romik-kelesh?source=rss-2f8105eab115------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*H7mxunOYeaN-DCjQDS4KkQ.png</url>
            <title>Stories by Romik Kelesh on Medium</title>
            <link>https://medium.com/@romik-kelesh?source=rss-2f8105eab115------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 02:44:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@romik-kelesh/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Web Scraping with Proxies]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/swlh/web-scraping-with-proxies-2cfcd98ba1cd?source=rss-2f8105eab115------2"><img src="https://cdn-images-1.medium.com/max/929/1*6BGz20svGYlNBCqB_feP_w.png" width="929"></a></p><p class="medium-feed-snippet">You have probably already experienced it, if during the scraping, the IP&#x200A;&#x2014;&#x200A;address is blocked, because one does not respect the robots.txt&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/swlh/web-scraping-with-proxies-2cfcd98ba1cd?source=rss-2f8105eab115------2">Continue reading on The Startup »</a></p></div>]]></description>
            <link>https://medium.com/swlh/web-scraping-with-proxies-2cfcd98ba1cd?source=rss-2f8105eab115------2</link>
            <guid isPermaLink="false">https://medium.com/p/2cfcd98ba1cd</guid>
            <category><![CDATA[bots]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[web-scraping]]></category>
            <category><![CDATA[proxy]]></category>
            <dc:creator><![CDATA[Romik Kelesh]]></dc:creator>
            <pubDate>Mon, 27 Dec 2021 13:22:43 GMT</pubDate>
            <atom:updated>2021-12-27T13:22:43.479Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[How to Solve Google — reCAPTCHA v3 with Python]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/geekculture/how-to-solve-google-recaptcha-v3-with-python-9f92bb0212bf?source=rss-2f8105eab115------2"><img src="https://cdn-images-1.medium.com/max/1080/1*O-AzEH4hlMuhlOy_Z0A4xg.png" width="1080"></a></p><p class="medium-feed-snippet">When creating web bots or web scrapers, very often you come across obstacles of any kind and moreover, with time, they become more and&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/geekculture/how-to-solve-google-recaptcha-v3-with-python-9f92bb0212bf?source=rss-2f8105eab115------2">Continue reading on Geek Culture »</a></p></div>]]></description>
            <link>https://medium.com/geekculture/how-to-solve-google-recaptcha-v3-with-python-9f92bb0212bf?source=rss-2f8105eab115------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f92bb0212bf</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[web-scraping]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Romik Kelesh]]></dc:creator>
            <pubDate>Sat, 24 Apr 2021 01:03:54 GMT</pubDate>
            <atom:updated>2021-04-25T22:48:46.041Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[10 Books and Courses for Getting Into Data Science]]></title>
            <link>https://medium.com/swlh/10-books-and-courses-for-getting-into-data-science-c2a081e9d1af?source=rss-2f8105eab115------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2a081e9d1af</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[how-to]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Romik Kelesh]]></dc:creator>
            <pubDate>Mon, 23 Nov 2020 23:42:50 GMT</pubDate>
            <atom:updated>2020-11-24T22:56:59.143Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_5CUS49qcGvxdiLQV8QANg.png" /></figure><p>By now, everyone who wants to get started in Data Science knows the requirements and what you have to learn.</p><p>The most difficult part is knowing which resources to use. Because some have a technical background and some do not. Some have a degree and some don’t.</p><p>In this article I would like to give you my personal recommendations on the respective topics in Data Science.<br>I have read several books and taken online courses and was able to compare in practice which ones helped me more and which ones helped me less.<br>Which ones just jumped on the hype and which ones provide really relevant and qualitative, realistic content.</p><p>Last but not least I would like to add, I have <strong>no cooperation</strong> with the course instructors or authors of the books. This is <strong>my</strong> personal opinion.</p><p>In some areas I may not be able to recommend a book to you, because I have not used it on these topics myself.<br>However, I am very sure that there is a good literature available in any case.</p><p><strong>Let’s start!</strong></p><h3>1. Python — Programming</h3><p><strong>Books</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*9TnE_5VvoeOILiICkBm74Q.png" /><figcaption>Automate the Boring Stuff with Python, by Al Sweigart</figcaption></figure><p>To have a solid and strong foundation in Python, I recommend this book:<br><a href="https://automatetheboringstuff.com/"><strong>Automate the Boring Stuff with Python</strong></a>, by Al Sweigart.</p><p>It not only teaches you the basic and essential content in Python, such as the difference between functional and object-oriented programming, but also other topics that are very interesting and necessary.</p><p>- Dealing with regular expressions<br>- Debugging<br>- Web scraping<br>- Work with Excel and Google Sheets, PDF, Word documents, CSV files and JSON data <br>- Keeping Time, Scheduling Tasks, and Launching Programs<br>- Send emails and much more.</p><p>The reason why I like Al Sweigart’s book is that you can start your own small projects right after, which are also very useful.</p><p>Analyzing PDF or Work documents for certain keywords, as well as your own emails.<br>Extract relevant data from different websites to perform various calculations and make automated decisions.</p><p>Thanks to this book, I have been able to perform several small, important tasks for my previous employers.</p><p><strong>Courses</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y08P-uGfPHKaE21HeFjCOw.png" /><figcaption>Udemy Course for his book</figcaption></figure><p>Al Sweigart has published a <a href="https://www.udemy.com/course/automate/?utm_source=adwords&amp;utm_medium=udemyads&amp;utm_campaign=Python_v.PROF_la.EN_cc.ROW_ti.7380&amp;utm_content=deal4584&amp;utm_term=_._ag_85724077624_._ad_478925752458_._kw__._de_c_._dm__._pl__._ti_dsa-774930046209_._li_9044748_._pd__._&amp;matchtype=b&amp;gclid=Cj0KCQiAkuP9BRCkARIsAKGLE8XVZiNYVdqh5jb7hLECx9z-DJw2uf02P-I9W771Y7HXRpJQTcjhEdkaAkuTEALw_wcB"><strong>Udemy Course</strong></a> for his book, which he tries to summarize in about 10 hours. Look at the ratings and you will see that the course is very popular.</p><p>He also has a <a href="https://www.youtube.com/channel/UCRjTEkDLPREZNlREZMlotMQ"><strong>YouTube — Channel</strong></a> where he presents some of the content from the book.</p><h3>2. Mathematics and Statistics</h3><p><strong>Books</strong></p><p>Unfortunately I cannot give you a book recommendation on this topic.</p><p>In my case, I studied computer science and economics and so I got my mathematical background.</p><p>Nevertheless, I would not like to leave this point just like that.</p><p>When it comes to mathematics in Machine Learning, often calculus, linear algebra and statistics, stochastics is recommended.</p><p>In my opinion, some topics are still missing, like numerics, graph theory, discrete mathematics and linear optimization.</p><p>Of course, you are good with the first four topics, but the last topics will give you the last reed.</p><p><strong>Courses</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jAPAa-k0rYbjoP2sReJ3SA.png" /><figcaption>Khan Academy</figcaption></figure><p><a href="https://de.khanacademy.org/"><strong>Khan Academy</strong></a> is still unbeatable when it comes to teaching mathematics.</p><p>However, I would like to mention a few others here that might explain various topics a little better and more clearly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*s2u-o3VK6q9N0x3Sp5zKnQ.png" /><figcaption>3Blue1Brown</figcaption></figure><p>For linear algebra, I recommend the Youtube — Channel of <a href="https://www.youtube.com/watch?v=fNk_zzaMoSs&amp;list=PLZHQObOWTQDPD3MizzM2xVFitgF8hE_ab"><strong>3Blue1Brown</strong></a>.<br>You learn through his videos, not only the calculations, but also how to visualize all this.</p><p>After his videos you will understand pretty well why eigenvalues and eigenvectors are used for the principal component analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*VEWqO1blbP7eA2AfKYKYKQ.jpeg" /><figcaption>Krista King</figcaption></figure><p><a href="https://www.udemy.com/user/kristaking/"><strong>Krista King</strong></a><strong> </strong>explains some topics in mathematics quite well too.<br>She offers several courses, which bring you closer to the contents relatively fast and understandable. I would highly recommend her statistics and probability course.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/180/1*v3ZEegTv1663bm2ZEoE9EQ.jpeg" /><figcaption>John Starmer</figcaption></figure><p>On some topics in stochastics like p-values and distributions.<br><a href="https://www.youtube.com/user/joshstarmer"><strong>John Starmer</strong></a> explains these very well and graphically, in his Youtube-Channel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*vOJYAZ8MlPZ_9zLgzSPaCA.jpeg" /><figcaption>Mike Cohen</figcaption></figure><p>Finally, I recommend the courses from <a href="https://www.udemy.com/user/mike-x-cohen/"><strong>Mike Cohen</strong></a>.<br>His linear algebra is comparable to the quality of <strong>3Blue1Brown</strong>, in my opinion. The only problem is that he uses the MATLAB language,instead of Python, but we are only concerned here with mathematical understanding, not with programming.<br>He also offers courses in signal processing, fourier transform and some more.</p><h3>3. NumPy and Pandas</h3><p><strong>Books</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/381/1*OfKE_gRa03sVAOaCIh7cXw.jpeg" /><figcaption>Python for Data Analysis, by Wes MckKinney</figcaption></figure><p><a href="https://www.amazon.com/Python-Data-Analysis-Wrangling-IPython/dp/1491957662/ref=asc_df_1491957662/?tag=googshopde-21&amp;linkCode=df0&amp;hvadid=310817730623&amp;hvpos=&amp;hvnetw=g&amp;hvrand=3560805384095278722&amp;hvpone=&amp;hvptwo=&amp;hvqmt=&amp;hvdev=c&amp;hvdvcmdl=&amp;hvlocint=&amp;hvlocphy=9044748&amp;hvtargid=pla-396828636441&amp;psc=1&amp;th=1&amp;psc=1&amp;tag=&amp;ref=&amp;adgrpid=70301320788&amp;hvpone=&amp;hvptwo=&amp;hvadid=310817730623&amp;hvpos=&amp;hvnetw=g&amp;hvrand=3560805384095278722&amp;hvqmt=&amp;hvdev=c&amp;hvdvcmdl=&amp;hvlocint=&amp;hvlocphy=9044748&amp;hvtargid=pla-396828636441"><strong>Wes MckKinney</strong></a> is the creator of Pandas and published a book about it.<br><a href="https://www.amazon.de/Python-Data-Analysis-Wrangling-IPython/dp/1491957662/ref=asc_df_1491957662/?tag=googshopde-21&amp;linkCode=df0&amp;hvadid=310817730623&amp;hvpos=&amp;hvnetw=g&amp;hvrand=13810536992829354984&amp;hvpone=&amp;hvptwo=&amp;hvqmt=&amp;hvdev=c&amp;hvdvcmdl=&amp;hvlocint=&amp;hvlocphy=9044748&amp;hvtargid=pla-396828636441&amp;psc=1&amp;th=1&amp;psc=1&amp;tag=&amp;ref=&amp;adgrpid=70301320788&amp;hvpone=&amp;hvptwo=&amp;hvadid=310817730623&amp;hvpos=&amp;hvnetw=g&amp;hvrand=13810536992829354984&amp;hvqmt=&amp;hvdev=c&amp;hvdvcmdl=&amp;hvlocint=&amp;hvlocphy=9044748&amp;hvtargid=pla-396828636441"><strong>Python for Data Analysis</strong></a><strong>.</strong></p><p>The book is really recommendable, because <strong>Wes MckKiney</strong> goes into this book very precisely and in detail about the characteristics of pandas.</p><p>When the creator of the library releases a book about it, it is no longer necessary to say more about why it is good.</p><p><strong>Courses</strong></p><p>NumPy and Pandas are completed in online courses, always quite fast and on the side.</p><p>I think you should pay more attention to these libraries.<br>Do you know, for example, why is a NumPy array faster than a normal list?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*8SW8qHYH9HwVf1yC8oKMVQ.jpeg" /><figcaption>Keith Galli</figcaption></figure><p><strong>Keith Galli</strong> is a graduate of MIT and has two videos on his YouTube-Channel, where he explains the characteristics of <a href="https://www.youtube.com/watch?v=GB9ByFAIAH4"><strong>NumPy </strong></a>and <a href="https://www.youtube.com/watch?v=vmEHCJofslg"><strong>Pandas</strong></a> clearly and precisely.</p><h3>4. Data Visualization</h3><p><strong>Courses</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/262/1*hzviHrcd9N4JFk324-LFdg.jpeg" /><figcaption>Jose Portilla</figcaption></figure><p><strong>Jose Portilla</strong> has in his course, <a href="https://www.udemy.com/course/python-for-data-science-and-machine-learning-bootcamp/"><strong>Python for Data Science and Machine Learning Bootcamp</strong></a>, some videos, where he also goes into <strong>matplotlib</strong> and <strong>seaborn</strong>.</p><p>In his course, he gives a lot of examples on these topics and also some tasks you can do by yourself.</p><p>Additionally he shows in some places, where visualization can deceive and which visualization techniques should be used for various problems.</p><p>Visualization should not be underestimated in any case. It is an extremely powerful and meaningful tool of a data scientist.</p><p>Visualizing comparisons, trends or anomalies not only provides clarity, but also helps people who don’t know anything about data science to understand the problem or issue.</p><h3>5. Machine Learning and Deep Learning</h3><p><strong>Books</strong></p><p>Actually I would suggest the book <a href="http://faculty.marshall.usc.edu/gareth-james/ISL/"><strong>Introduction to Statistical Learning</strong></a>, but for many beginners it is too mathematical and a bit daunting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*q5hXYaWM88ZoDUXjeGztgw.jpeg" /><figcaption>Data Science from Scratch by Joel Grus</figcaption></figure><p>Therefore, for machine learning, I would recommend the book <a href="https://www.amazon.com/Data-Science-Scratch-Principles-Python/dp/1492041130"><strong>Data Science from Scratch</strong></a> by Joel Grus instead.</p><p>Joel Grus is a former software developer of Google and has created a really small masterpiece with this book.</p><p>When most people start with machine learning, they get to know the <strong>scikit-learn</strong> library right from the start and learn the algorithms a bit superficially in my opinion.</p><p>Joel Grus starts his book with some other topics in the first chapters, like the programming language Python, statistics, stochastics, linear algebra and data visualization. After that he goes into the topic of machine learning.</p><p>Why I recommend this book so much? Every topic that appears in his book, he not only explains the theme in short sentences, but he explains it again by programming it in Python.</p><p>On the topic of <strong>Deep Learning</strong> the book by Tariq Rashid is excellent.</p><p>Tariq Rashid is head of the London Python-Meetup group with 3,000 members.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/195/1*WJI2k6LVxB7MUmukSiRK8w.jpeg" /><figcaption>Make Your Own Neural Network by Tariq Rashid</figcaption></figure><p>In his book <a href="https://www.amazon.de/Make-Your-Own-Neural-Network/dp/1530826608"><strong>Make Your Own Neural Network</strong></a> he goes from a little story about artificial intelligence to the development of an artificial neural networks.</p><p>Already in the first chapter he gives a small but clear example of <strong>how</strong> and <strong>why</strong> the error leads to the model being improved.</p><p>In his book, as the title suggests, he explains how to program your own artificial neural network with python, step by step.</p><p>He explains the mathematical conditions and fineness, incredibly comprehensible and very simple.</p><p>I recommend everyone who starts with deep learning to program your first artificial neural network from scratch.</p><p><strong>Courses</strong></p><p>Here I suggest two courses of Coursera.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/180/1*fkVSVbRV_gVr1xMqGaKUbA.jpeg" /><figcaption>Andrew Ng</figcaption></figure><p>On the subject of machine learning, I recommend the course of <a href="https://de.coursera.org/learn/machine-learning?="><strong>Andrew Ng — Machine Learning</strong></a>, this course is unbeatable in my opinion and whoever deals with data science or the subject of machine learning will inevitably come across him.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*906OPo9ZqVN1_2mw2Fk98A.png" /><figcaption>deeplearning.ai</figcaption></figure><p>For deep learning I advise the course from <a href="https://de.coursera.org/specializations/deep-learning"><strong>deeplearning.ai</strong></a> .<br>One of the lecturers is again Andrew Ng. In this course you learn not only common artificial neural networks, but also convolutional neural networks for image recognition.</p><p>If you want to learn the necessary libraries for machine learning, like scikit-learn, tensorflow and keras, I recommend to read the documentation for these libraries or to visit the courses for these libraries on Youtube, Udacity or Udemy.</p><p>In my opinion it is first and foremost important to understand the machine learning algorithms and the theory behind them and especially for what purposes you use them.</p><h3>6. Flask and Flask-RESTful</h3><p><strong>Courses</strong></p><p>This point is rarely or not at all mentioned by others.<br>In my opinion it is extremely important. Not only to develop a small web application, but also an API that you make available to others.<br>For example, an already trained API to recognize company logos, or an API that makes predictions based on various data using a machine learning algorithm.</p><p>You can make this API available to other programmers in the world, for free or for a fee. <br>Believe me when I tell you that learning Flask will only benefit you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*HmlkXCVrzWuuOLIugrgwMA.jpeg" /><figcaption>Jose Salvatierra</figcaption></figure><p>To learn Flask, I recommend the course by <a href="https://www.udemy.com/course/rest-api-flask-and-python/"><strong>Jose Salvatierra</strong></a>.<br>He will teach you not only how to use Flask, Flask API, but also how to make it safe using JWT.<br>You will also get an introduction to Git, which is also very important for version control.</p><h3>7. SQL and NoSQL</h3><p><strong>Courses</strong></p><p>Let us now come to the important, if not the most important area in data science, namely databases and database languages.</p><p>It is well known by now that the development of machine learning models does not take as much time as cleaning, structuring, modifying and analyzing data.</p><p>While we are on the subject of data science, data is of course the most important thing.</p><p>Knowing how to retrieve this data from a database and how to design the queries is incredibly essential.</p><p>It is very often the case that in reality you work with impure, inaccurate, unstructured and missing data.<br>Knowing how to deal with this is an art in itself.</p><p>Let’s say you have features that show growth figures or ratios.<br>And these features have missing or incorrect values in some places.<br>Simply calculating the median, the mode or the average is not always the best.<br>In our case, you should rather make the geometric or harmonic mean.<br>Or you have to deal with nominally scaled data, such as the feature, the favorite fruit of your users.<br>What do you do if there are values missing? We are not talking about 1 or 2 data sets, where it is not noticeable at all with a large amount of data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*GrT0iZdvhenGe2yA8RSWWw.png" /><figcaption>freeCodeCamp.org</figcaption></figure><p>For <a href="https://www.youtube.com/watch?v=HXV3zeQKqGY"><strong>SQL</strong></a> and <a href="https://www.youtube.com/watch?v=pWbMrx5rVBE"><strong>NoSQL</strong></a>, I recommend the courses from <strong>freeCodeCamp.org</strong> and <strong>Traversy Media</strong> on Youtube.</p><p>The two videos on the topics are very popular (SQL 5.2 million and NoSQL 1.7 million views).</p><h3>Conclusion</h3><p>I’m sure that there are some people who think that other books or courses are better or who think that some other topics should be added.</p><p>Data science is, in my eyes, still not a clearly defined field.</p><p>I have often been confronted with the fact that some data scientists are actually more data engineers or machine learning engineers. Some are even completely software developers or business intelligence, web or business analysts.</p><p>This is only because data science can be found in almost every field and it is honestly a buzzword that is very popular in the industry.</p><p>I slowly realize that the clear separation is coming, but it still takes time.</p><p>This is my view of what makes a data scientist. If you have a different opinion, please tell me about your experience.<br>Because I am very interested in the different facets of data science in this world.</p><p>I hope I could help you with my contribution and if you have any questions, please do not hesitate.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2a081e9d1af" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/10-books-and-courses-for-getting-into-data-science-c2a081e9d1af">10 Books and Courses for Getting Into Data Science</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to deploy a Python — Web Scraper with Selenium on Heroku]]></title>
            <link>https://romik-kelesh.medium.com/how-to-deploy-a-python-web-scraper-with-selenium-on-heroku-1459cb3ac76c?source=rss-2f8105eab115------2</link>
            <guid isPermaLink="false">https://medium.com/p/1459cb3ac76c</guid>
            <category><![CDATA[selenium]]></category>
            <category><![CDATA[web-scraping]]></category>
            <category><![CDATA[heroku]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Romik Kelesh]]></dc:creator>
            <pubDate>Thu, 30 Jul 2020 15:04:39 GMT</pubDate>
            <atom:updated>2021-08-17T10:56:23.611Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to deploy a Python — Web Scraper with Selenium on Heroku</h3><figure><img alt="Heroku — Logo and a spider with Selenium — Library Logo" src="https://cdn-images-1.medium.com/max/1024/1*qGrPaOq22aGAOSGMSKoHOQ.png" /></figure><p>Anyone who starts with web scraping gets to the point where they don’t want to run it on their computer anymore, but on a cloud and if possible for free.</p><p>Deploying web scrapers on Heroku is not that difficult.<br>However, if you want to do this in combination with Selenium, there are a few things to consider.</p><p>In this article, I will explain everything in a bit more detail, because I am aware that some of the readers are beginners.</p><h3>Web Scraper — Example</h3><p>For the illustration purposes I created a small web scraper.<br>The web scraper goes to the Medium page and outputs the source of the page.</p><p>Nothing complicated.</p><pre>from selenium import webdriver<br></pre><pre>driver = webdriver.Chrome()</pre><pre>driver.get(&quot;https://medium.com&quot;)</pre><pre>print(driver.page_source)</pre><pre><br>driver.quit()</pre><pre>print(&quot;Finished!&quot;)</pre><h3>Set up our code for Heroku</h3><h4>Add some arguments to Chrome-Options</h4><p>At the beginning we have to change our code a little bit, so that our web scraper can run on Heroku.</p><p>First we have to import the osmodule.<br>The os module provides a portable way of using operating system dependent functionality.</p><p>In our case we need it to access Heroku’s environment variables.</p><p>For those who don’t know: an environment variable is made of a name/value pair, whose value is set outside the program.<br>It affects the way running processes behave on a computer.</p><pre>from selenium import webdriver<br>import os</pre><p>Now we have to make some necessary settings for our chrome driver.</p><pre>chrome_options = webdriver.ChromeOptions()<br></pre><pre>chrome_options.add_argument(&quot;--headless&quot;)</pre><pre>chrome_options.add_argument(&quot;--disable-dev-shm-usage&quot;)</pre><pre>chrome_options.add_argument(&quot;--no-sandbox&quot;)</pre><ul><li>The headless argument doesn’t open the browser, when the web scraper is running and so it runs in the background. It is also required by Heroku himself, if it has not changed.</li></ul><p>To explain the utility of the arguments --no-sandbox and --disable-dev-shm-usagein detail, we would need another blog post, but in short:</p><ul><li>sandbox is an additional feature from Chrome, which aren’t included on the Linux box that Heroku spins up for you. Therefore, we do not want to have a sandbox.</li><li>/dev/shm is an implementation of the traditional shared memory concept. <br>The shared memory space is typically too small for Chrome and will cause Chrome to crash when rendering large pages. <br>In the past, the size of the shared memory had to be increased. <br>Since Chrome Version 65, this is no longer necessary. Instead, launch the browser with the--disable-dev-shm-usageflag. <br>This will write shared memory files into /tmp instead of /dev/shm.</li></ul><p>For those who wants to know more, I added following two links:</p><ul><li>no-sandbox: <a href="https://www.google.com/googlebooks/chrome/med_26.html">https://www.google.com/googlebooks/chrome/med_26.html</a></li><li>disable-dev-shm-usage: <a href="https://www.cyberciti.biz/tips/what-is-devshm-and-its-practical-usage.html">https://www.cyberciti.biz/tips/what-is-devshm-and-its-practical-usage.html</a></li></ul><h4>Storing the paths in Heroku’s — Environment Variables</h4><pre>chrome_options.binary_location = os.environ.get(&quot;GOOGLE_CHROME_BIN&quot;)</pre><pre>driver = webdriver.Chrome(executable_path=os.environ.get(&quot;CHROMEDRIVER_PATH&quot;), chrome_options=chrome_options)</pre><p>As already mentioned in the subtitle, we store the paths for Heroku’s environment variables here, once for google-chrome and the chromedriver.</p><p>So the complete code should finally look like this.</p><pre>from selenium import webdriver</pre><pre>import os</pre><pre>chrome_options = webdriver.ChromeOptions()</pre><pre>chrome_options.add_argument(&quot;--headless&quot;)</pre><pre>chrome_options.add_argument(&quot;--disable-dev-shm-usage&quot;)</pre><pre>chrome_options.add_argument(&quot;--no-sandbox&quot;)</pre><pre>chrome_options.binary_location = os.environ.get(&quot;GOOGLE_CHROME_BIN&quot;)</pre><pre>driver = webdriver.Chrome(executable_path=os.environ.get(&quot;CHROMEDRIVER_PATH&quot;), chrome_options=chrome_options)<br></pre><pre>driver.get(&quot;https://medium.com&quot;)<br></pre><pre>print(driver.page_source)</pre><pre>print(&quot;Finished!&quot;)</pre><h3>Preparation for deployment</h3><h4>Virtual environment</h4><p>Depending on the operating system you have ( I use Windows ) open your command line and change to your project folder.</p><pre>C:\Users\Romik&gt;cd Desktop</pre><pre>C:\Users\Romi\Desktop&gt;cd myproject</pre><pre>C:\Users\Romi\Desktop\myproject&gt;</pre><p>Then, if you don’t already have it, install the Python package virtualenv.</p><pre>C:\Users\Romi\Desktop\myproject&gt;pip install virtualenv</pre><p>Now create your virtual environment and give it a name. Usually people give it the name env for environment.</p><pre>C:\Users\Romi\Desktop\myproject&gt;virtualenv env</pre><p>And now you have to activate the virtual environment.</p><pre>C:\Users\Romi\Desktop\myproject&gt;env\Scripts\activate</pre><pre>(env) C:\Users\Romi\Desktop\myproject&gt;</pre><h4>Requirements and installation of the modules</h4><p>Now you have to install all modules you use in your project in this virtual environment.</p><p>In our case it is only selenium, because os is already one of the standard modules of Python.</p><pre>(env) C:\Users\Romi\Desktop\myproject&gt; pip install selenium</pre><p>Heroku also requires two files, one is the requirements.txt file which lists all your installed modules and their versions, and the other is the Procfileto know how to run your code.</p><pre>(env) C:\Users\Romi\Desktop\myproject&gt; pip freeze &gt; requirements.txt</pre><p>Therequirements.txt must now be located in your project folder.</p><pre>(env) C:\Users\Romi\Desktop\myproject&gt; echo worker: python main.py &gt; Procfile</pre><p>Depending on what operating system you have, you will need to use different commands to create a Procfile file.<br>In the end, the Procfilefile must only contain the following command or content.</p><figure><img alt="Procfile" src="https://cdn-images-1.medium.com/max/683/1*fqREOttbFB19TXGa7vrJZw.png" /></figure><p>You just have to tell the worker in the Procfilewhich command to execute.<br>In our case, it should execute the Python file with our written code.<br>Heroku will search for this Procfileand then execute the command it contains.</p><p>Your folder should look like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/257/1*WIhOtmpQokcJC-a1Jas3bA.png" /></figure><h3>Deploying to Heroku</h3><h4>First things first</h4><p>Create an account on Heroku, if you don’t already have one.<br>Don’t worry, you won’t have to give your credit card details.<br>It is not necessary for our use case.</p><p>After you have logged in, create a new app.</p><figure><img alt="Heroku — Create App Image" src="https://cdn-images-1.medium.com/max/521/1*moCiUXPvfDipfyNbSgIbCA.png" /></figure><p>Name the app what you want. The choice of region is not so relevant in our case. So choose for that also whatever you want.</p><figure><img alt="Name app and choose region" src="https://cdn-images-1.medium.com/max/825/1*2YvK4v8m2HorqBGWj4hWTA.png" /></figure><p>After all these steps, you should have arrived at this view.</p><figure><img alt="Heroku — Personal" src="https://cdn-images-1.medium.com/max/1024/1*EGI5L5bwjzTVWXfjXDJfMQ.png" /></figure><h4>Environment variables</h4><p>Change the tab to Settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_E7qtgWcZUhNkWV211h5pA.png" /></figure><p>Do you remeber &quot;GOOGLE_CHROME_BIN&quot; and &quot;CHROMEDRIVER_PATH&quot; from this code snippet below?</p><pre>chrome_options.binary_location = os.environ.get(&quot;GOOGLE_CHROME_BIN&quot;)</pre><pre>driver = webdriver.Chrome(executable_path=os.environ.get(&quot;CHROMEDRIVER_PATH&quot;), chrome_options=chrome_options)<br></pre><p>We will now use them in our application.</p><figure><img alt="Environment variables" src="https://cdn-images-1.medium.com/max/1024/1*f8-9A6dj4FiG5l-XBUy5Lw.png" /></figure><p>Under the Config Vars section, click the Reveal Config Vars button and fill out the input fields.</p><p>Key: CHROMEDRIVER_PATH Value: /app/.chromedriver/bin/chromedriver</p><p>Key: GOOGLE_CHROME_BIN Value: /app/.apt/usr/bin/google-chrome</p><h4>Buildpacks</h4><p>Buildpacks are scripts that are run when your app is deployed. They are used to install dependencies for your app and configure your environment.</p><p>You can also find them under the settings tab, directly below theConfig Varssection.</p><figure><img alt="Buildpack — Python" src="https://cdn-images-1.medium.com/max/1024/1*l9q8FNWwSRN5xfF0N7oCkw.png" /></figure><figure><img alt="Buildpack — 2" src="https://cdn-images-1.medium.com/max/588/1*3gFWVq7NNSibkka3nVi13Q.png" /></figure><figure><img alt="Buildpack-3" src="https://cdn-images-1.medium.com/max/588/1*jyTqkaJDrDGbaAAZpTGRqg.png" /></figure><p>These are the three buildpacks we need.</p><p>Links for the last two:</p><ul><li><a href="https://github.com/heroku/heroku-buildpack-google-chrome">https://github.com/heroku/heroku-buildpack-google-chrome</a></li><li><a href="https://github.com/heroku/heroku-buildpack-chromedriver">https://github.com/heroku/heroku-buildpack-chromedriver</a></li></ul><h4>Ready for deployment</h4><p>Go to the Deploytab, and under theDeployment method section, select the Heroku Git/CLI option.</p><p>Besides theHeroku Git/CLI, there are of course the two other methods like GitHub and Container Registry, but I decided to use the first method in this blog.</p><p>Finally, follow the instructions in the Deploy using Heroku Git section.<br>The installation of the Heroku CLI is quite straightforward.</p><figure><img alt="Deploy Heroku" src="https://cdn-images-1.medium.com/max/813/1*yLxBpDL0tC_W6nRLyHzlTw.png" /></figure><h4>Last step</h4><p>Now you have to assign a dyno that does the work. <br>Type heroku ps:scale worker=1</p><p>In case you are wondering what <em>dynos</em> are, in short, they are the heart of Heroku.<br>You can find more details here: <a href="https://www.heroku.com/dynos">https://www.heroku.com/dynos</a></p><p>Now your code will continue to run until you stop the dyno. To stop the dyno, use the command heroku ps:scale worker=0</p><p>If you want to check the logs to make sure its working correctly, type heroku logs --tail.</p><h4>Thank you for reading</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1459cb3ac76c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>