<?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 Vaibhav Gupta on Medium]]></title>
        <description><![CDATA[Stories by Vaibhav Gupta on Medium]]></description>
        <link>https://medium.com/@vaibhgupt199?source=rss-e63492d1e932------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*gspQhnpDtGz9bdapr7c9zg.jpeg</url>
            <title>Stories by Vaibhav Gupta on Medium</title>
            <link>https://medium.com/@vaibhgupt199?source=rss-e63492d1e932------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 02:58:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vaibhgupt199/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[How I used Python to help me chose an organisation for Google Summer of Code ‘19]]></title>
            <link>https://medium.com/free-code-camp/how-i-used-python-to-help-me-chose-an-organisation-for-google-summer-of-code-19-75078de13194?source=rss-e63492d1e932------2</link>
            <guid isPermaLink="false">https://medium.com/p/75078de13194</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[web-scraping]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[gsoc]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Vaibhav Gupta]]></dc:creator>
            <pubDate>Thu, 10 Jan 2019 16:59:38 GMT</pubDate>
            <atom:updated>2019-01-10T16:59:38.607Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*ucoUbiOID-texxFdJ8v2jw.jpeg" /><figcaption>Image Credits: <a href="https://medium.com/@meets2tarun">Tarun Kumar</a></figcaption></figure><p>In this tutorial, I’ll be using python to scrape data from the Google Summer of Code (GSoC) archive about the participating organizations from the year 2009.</p><h3>My Motivation Behind This Project</h3><p>While I was scrolling through the huge list of organisations that participated in GSoC’18, I realised that exploring an organisation is a repetitive task - choose one, explore its projects, check that if it has participated in previous years or not. But, there are 200+ organizations, and going through them all would take a whole lot of time. So, being a lazy person, I decided to use python to ease my work</p><h3>Requirements</h3><ul><li><em>Python (I’ll be using python3.6, because f-strings are awesome 🔥)</em></li><li><em>Pipenv (for virtual environment)</em></li><li><em>requests (for fetching the web page)</em></li><li><em>Beautiful Soup 4 (for extracting data from the web pages)</em></li></ul><h3>Building Our Script</h3><p>These are the web pages which we are going to scrape:</p><ol><li>For the years 2009–2015: <a href="https://www.google-melange.com/archive/gsoc">Link</a></li><li>For the years 2015–2018: <a href="https://summerofcode.withgoogle.com/archive/">Link</a></li></ol><h3>Coding Part</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*u5vEWeGuTXMWZiQQz8PbqQ.gif" /><figcaption><a href="https://giphy.com/gifs/nascar-owen-wilson-daytona-500-xTiN0GMUaOI726QYZa">GIF from Giphy</a></figcaption></figure><h4>Step 1: Setting up the virtual environment and installing the dependencies</h4><p><em>virtualenv</em> can be used to create a virtual environment, but I would recommend using <em>Pipenv </em>because<em> </em>it minimizes the work and supports <em>Pipfile </em>and <em>Pipfile.lock</em>.</p><p>Make a new folder and enter the following series of commands in the terminal:</p><pre>pip install pipenv</pre><p>Then create a virtual environment and install all the dependencies with just a single command (Pipenv rocks 🎉):</p><pre>pipenv install requests beautifulsoup4 --three</pre><p>The above command will perform the following tasks:</p><ul><li>Create a virtual environment (for python3).</li><li>Install <em>requests</em> and b<em>eautifulsoup4.</em></li><li>Create Pipfile and Pipfile.lock in the same folder.</li></ul><p>Now, activate the virtual environment:</p><pre>pipenv shell</pre><p>Notice the name of the folder before $ upon activation like this:</p><pre>(gsoc19) $</pre><h4>Step 2: Scraping data for the years 2009–2015</h4><p>Open any code editor and make a new python file (I will name it 2009–2015.py). The webpage contains the links for the list of organizations of each year. First, write a utility function in a separate file utils.py which will GET any webpage for us and will raise an Exception if there’s a connection error.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fffb4af2825bfa2cc4b874ef0b65215f/href">https://medium.com/media/fffb4af2825bfa2cc4b874ef0b65215f/href</a></iframe><p>Now, get the link of the web page which contains the list of organizations for each year.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*pyKlRbBI5wfHuxFmSxoWjQ.png" /><figcaption>Webpage preview</figcaption></figure><p>For that, create a function get_year_with_link. Before writing the function, we need to inspect this webpage a little. Right-click on any year and click on <em>Inspect</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4qOIYUKISEcOIPcshCZ8KQ.png" /></figure><p>Note that there’s a &lt;ul&gt; tag, and inside it, there are &lt;li&gt; tags, each of which contains a &lt;span&gt; tag with class mdl-list__item-primary-content, inside of which is our link and year. Also, notice that this pattern is the same for each year. We want to grab that data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0bf197444cb7ca2bafc9f344c3ef9703/href">https://medium.com/media/0bf197444cb7ca2bafc9f344c3ef9703/href</a></iframe><p>The tasks performed by this function are in this order:</p><ol><li>Get the MAIN_PAGE, raise an exception if there’s a connection error.</li><li>If the response code is 200 OK, parse the fetched webpage with BeautifulSoup. And if the response code is something else, exit the program.</li><li>Find all the &lt;li&gt; tags with class mdl-list__item mdl-list__item — one-line and store the returned list in years_li.</li><li>Initialize an empty years_dict dictionary.</li><li>Start iterating over the years_li list.</li><li>Get the year text (2009, 2010, 2011,…), remove all \n, and store it in the year.</li><li>Get the relative link of each year (/archive/gsoc/2015, /archive/gsoc/2016,…) and store it in the relative_link.</li><li>Convert the relative_link into the full link by combining it with the HOME_PAGE link and store it in full_link.</li><li>Add this data to the year_dict dictionary with the year as key and full_link as its value.</li><li>Repeat this for all years.</li></ol><p>This will give us a dictionary with years as keys and their links as values in this format:</p><pre>{<br>  ...<br>  &#39;2009&#39;: &#39;<a href="https://www.google-melange.com/archive/gsoc/2009&#39;">https://www.google-melange.com/archive/gsoc/2009&#39;</a>,<br>  &#39;2010&#39;: &#39;<a href="https://www.google-melange.com/archive/gsoc/2010&#39;">https://www.google-melange.com/archive/gsoc/2010&#39;</a>,<br>  ...<br>}</pre><p>Now, we want to visit these links and get the name of every organization with their links from these pages. Right-click on any org name and click on <em>Inspect</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ISaEmvazH3dr8Knfe3MtqA.png" /></figure><p>Note that there’s a &lt;ul&gt; tag with class mdl-list, which has &lt;li&gt; tags with class mdl-list__item mdl-list__item — one-line. Inside of each there’s an &lt;a&gt; tag which has the link and the organization’s name. We want to grab that. For that, let’s create another function get_organizations_list_with_links, which takes the links of web pages which contains the organizations&#39; list for each year (which we scraped in get_year_with_link).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/90d3f1581f9a7f04518ec8d07c096558/href">https://medium.com/media/90d3f1581f9a7f04518ec8d07c096558/href</a></iframe><p>The tasks performed by this function are in this order:</p><ol><li>Get the org list page, (<a href="https://www.google-melange.com/archive/gsoc/2015">https://www.google-melange.com/archive/gsoc/2015</a>, <a href="https://www.google-melange.com/archive/gsoc/2015">https://www.google-melange.com/archive/gsoc/201</a>6, ….), raise an exception if there’s a connection error.</li><li>If the response code is 200 OK, parse the fetched webpage with BeautifulSoup. And if the response code is something else, exit the program.</li><li>Find all the &lt;li&gt; tags with class mdl-list__item mdl-list__item — one-line and store the returned list in orgs_li.</li><li>Initialize an empty orgs_dict dictionary.</li><li>Start iterating over the orgs_li list.</li><li>Get the org name, remove all \n, and store it in the org_name .</li><li>Get the relative link of each org (/archive/gsoc/2015/orgs/n52, /archive/gsoc/2015/orgs/beagleboard,…) and store it in the relative_link.</li><li>Convert the relative_link into the full link by combining it with the HOME_PAGE link and store it in full_link.</li><li>Add this data to the orgs_dict with the org_name as key and full_link as its value.</li><li>Repeat this for all the organizations for a particular year.</li></ol><p>This will give us a dictionary with organizations’ names as keys and their links as values, like this:</p><pre>{<br>  ...<br>  &#39;ASCEND&#39;: &#39;<a href="https://www.google-melange.com/archive/gsoc/2015/orgs/ascend">https://www.google-melange.com/archive/gsoc/2015/orgs/ascend</a>&#39;,</pre><pre>&#39;Apache Software Foundation&#39;: &#39;<a href="https://www.google-melange.com/archive/gsoc/2015/orgs/apache">https://www.google-melange.com/archive/gsoc/2015/orgs/apache</a>&#39;,<br>  ...<br>}</pre><p>Moving ahead, we want to visit these links and get the title, description, and link of each project of each org for each year (😕). Right-click on any project’s title and click on <em>Inspect</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sb8nG8HeNSqrwUVG5BTiAQ.png" /></figure><p>Again, the same pattern. There’s a &lt;ul&gt; tag with class mdl-list which contains the &lt;li&gt; tags with class mdl-list__item mdl-list__item — two-line, inside of which there’s an &lt;span&gt; which contains an &lt;a&gt; tag containing our project’s name. Also, there’s an &lt;span&gt; tag with class mdl-list__item-sub-title containing the project’s description. For that, create a function get_org_projects_info to get this task done.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9464238bbe643527a301fae266df22e2/href">https://medium.com/media/9464238bbe643527a301fae266df22e2/href</a></iframe><p>The tasks performed by this function are in this order:</p><ol><li>Get the org’s description page, (<a href="https://www.google-melange.com/archive/gsoc/2015/orgs/ascend">https://www.google-melange.com/archive/gsoc/2015/orgs/ascend</a>, <a href="https://www.google-melange.com/archive/gsoc/2015/orgs/apache">https://www.google-melange.com/archive/gsoc/2015/orgs/apache</a>, ….), raise an exception if there’s a connection error.</li><li>If the response code is 200 OK, parse the fetched webpage with BeautifulSoup. And if the response code is something else, exit the program.</li><li>Find all the &lt;li&gt; tags with class equal to mdl-list__item mdl-list__item — two-line and store the returned list in projects_li.</li><li>Initialize an empty projects_info list.</li><li>Start iterating over the projects_li list.</li><li>Initialize an empty dictionary proj_info in each loop.</li><li>Get the project’s title, remove all \n, and store it in the proj_title .</li><li>Get the relative link of each project (<a href="https://www.google-melange.com/archive/gsoc/2015/orgs/apache/projects/djkevincr.html">https://www.google-melange.com/archive/gsoc/2015/orgs/apache/projects/djkevincr.html</a>, ….) and store it in the proj_relative_link.</li><li>Convert the proj_relative_link into the full link by combining it with the HOME_PAGE link and store it in proj_full_link.</li><li>Store the project’s title, description and link in the proj_info dictionary and append this dictionary to the projects_info list.</li></ol><p>This will give us a list containing dictionaries with the project’s data.</p><pre>[<br>  ...<br>  {<br>    &#39;title&#39;: &#39;Project Title 1&#39;,<br>    &#39;description&#39;: &#39;Project Description 1&#39;,<br>    &#39;link&#39;: &#39;<a href="http://project-1-link.com/&#39;">http://project-1-link.com/&#39;</a>,<br>  },<br>  {<br>    &#39;title&#39;: &#39;Project Title 2&#39;,<br>    &#39;description&#39;: &#39;Project Description 2&#39;,<br>    &#39;link&#39;: &#39;<a href="http://project-2-link.com/&#39;">http://project-2-link.com/&#39;</a>,<br>  }<br>  ...<br>]</pre><h4>Step 3: Implementing the main function</h4><p>Let’s see the code first:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/42f627f62ec17407d826f1de1467b8af/href">https://medium.com/media/42f627f62ec17407d826f1de1467b8af/href</a></iframe><p>The tasks performed by this function are in this order:</p><ol><li>We want to have a final_dict dictionary so that we can save it as .json file.</li><li>Then, we call our function get_year_with_link(), which will return a dictionary with years as keys and links to the list of organizations as values and store it in year_with_link.</li><li>We iterate over the dictionary year_with_link.</li><li>For each year, we call the function get_organizations_list_with_links() with the link for it as the parameter, which will return a dictionary with organizations’ name as keys and links to the webpage containing information about them as values. We store the returning value in final_dict, with year as keys.</li><li>Then we iterate over each org for each year.</li><li>For each org, we call the function get_org_projects_info() with the link for the org as parameter, which will return a list of dictionaries containing each projects’ information.</li><li>We store that data in the final_dict.</li><li>After the loop is over, we will have a final_dict dictionary as follows:</li></ol><pre>{<br>    &quot;2009&quot;: {<br>        &quot;Org 1&quot;: [<br>            {<br>                &quot;title&quot;: &quot;Project - 1&quot;,<br>                &quot;description&quot;: &quot;Project-1-Description&quot;,<br>                &quot;link&quot;: &quot;<a href="http://project-1-link.com/">http://project-1-link.com/</a>&quot;<br>            },<br>            {<br>                &quot;title&quot;: &quot;Project - 2&quot;,<br>                &quot;description&quot;: &quot;Project-2-Description&quot;,<br>                &quot;link&quot;: &quot;<a href="http://project-2-link.com/">http://project-2-link.com/</a>&quot;<br>            }<br>        ],<br>        &quot;Org 2&quot;: [<br>            {<br>                &quot;title&quot;: &quot;Project - 1&quot;,<br>                &quot;description&quot;: &quot;Project-1-Description&quot;,<br>                &quot;link&quot;: &quot;<a href="http://project-1-link.com/">http://project-1-link.com/</a>&quot;<br>            },<br>            {<br>                &quot;title&quot;: &quot;Project - 2&quot;,<br>                &quot;description&quot;: &quot;Project-2-Description&quot;,<br>                &quot;link&quot;: &quot;<a href="http://project-2-link.com/">http://project-2-link.com/</a>&quot;<br>            }<br>        ]<br>    },<br>    &quot;2010&quot;: {<br>        ...<br>    }<br>}</pre><p>9. Then we will save it as a json file with json.dumps .🎉 😆</p><h4>Next Steps</h4><p>Data for the years 2016–2018 can be scraped in a similar manner. And then python (or any suitable language) can be used to analyze the data. Or, a web app can be made. In fact, I have already made my version of a webapp using <em>Django</em>, <em>Django REST Framework</em> and <em>ReactJS</em>. <strong>Here is the link for the same: </strong><a href="https://gsoc-data-analyzer.netlify.com/">https://gsoc-data-analyzer.netlify.com/</a></p><blockquote>All the code for this tutorial is available on my <a href="https://github.com/dojutsu-user/GSoC-Data-Analyser">github</a>.</blockquote><h3>Improvements</h3><p>The running time of the script can be improved by using Multithreading. Currently, it fetches one link at one time, it can be made to fetch multiple links simultaneously.</p><h3>About Me</h3><p>Hi there.</p><p>I am <strong>Vaibhav Gupta</strong>, an undergrad student at <strong>Indian Institute of Information Technology, Lucknow</strong>. I love Python and JS.</p><p>See my <a href="https://dojutsu-user.github.io/">portfolio</a> or find me on <a href="https://www.facebook.com/vaib79">Facebook</a>, <a href="https://www.linkedin.com/in/vaibhavgupta79/">LinkedIn</a> or <a href="https://github.com/dojutsu-user">Github</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75078de13194" width="1" height="1" alt=""><hr><p><a href="https://medium.com/free-code-camp/how-i-used-python-to-help-me-chose-an-organisation-for-google-summer-of-code-19-75078de13194">How I used Python to help me chose an organisation for Google Summer of Code ‘19</a> was originally published in <a href="https://medium.com/free-code-camp">We’ve moved to freeCodeCamp.org/news</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>