Okay, so I just started to learn Python.  I have been working through Dive Into Python 3 and the Google stuff (great exercises IMHO, totally fun).  However, with Dive, I had an issue with him referencing the files in the example directory, which from the website seem very unhandy.  Although I have since stumbled upon his GitHub, I made a Python script to grab those files for me and it works great, with the exception of doubling the line spacing.  So here is my code. I hope you critique the heck out of my and that you point out what I did wrong to introduce double line-spacing.  Thanks a bunch:<div>
<br></div><div><div>import os</div><div>import urllib.request</div><div>import re</div><div><br></div><div>url_root = &#39;<a href="http://diveintopython3.ep.io/examples/">http://diveintopython3.ep.io/examples/</a>&#39;</div>
<div>file_root = os.path.join(os.path.expanduser(&quot;~&quot;), &quot;diveintopython3&quot;, &quot;examples&quot;)</div><div><br></div><div>main_page = urllib.request.urlopen(url_root).read()</div><div>main_page = main_page.decode(&quot;utf-8&quot;)</div>
<div><br></div><div>pattern = &#39;href=&quot;([^&quot;].*?.)(py|xml)&quot;&#39;</div><div>matches = re.findall(pattern, main_page)</div><div>for my_tuple in matches:</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>this_file = my_tuple[0] + my_tuple[1] </div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>data = urllib.request.urlopen(url_root + this_file).read()</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>data = data.decode(&quot;utf-8&quot;)</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>with open(os.path.join(file_root, this_file), mode=&#39;w&#39;, encoding=&#39;utf-8&#39;) as a_file:</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>a_file.write(data)</div>
<div><br></div>-- <br>Mark :)<br>
</div>