title: Python - parsing HTML from HTTPS url using lxml - urllib2.urlopen workaround will not work
body: <p>I have a previously-working web scraper. However, the website which it is specifically designed to scrape from has recently changed to using HTTPS, making the relevant code excerpt below no longer work.</p>
  
  <pre><code>    from lxml import html
  
      url = 'http://www.blahblah.com'
      good_data = False
      while good_data ==False:
          try:
              data = html.fromstring(html.tostring(html.parse(url)))
              good_data=True
          except Exception:
              good_data=False
              print 'scraping failed'
              winsound.Beep(800,1000)
              time.sleep(pause)
  </code></pre>
  
  <p>Where previously the data would be successfully parsed into 'data', I now get an IOError from lxml.</p>
  
  <p>I did some reading - here in particular: <a href="https://stackoverflow.com/questions/3116269/error-with-parse-function-in-lxml">error with parse function in lxml</a> - and I attempted to implement the given solution using urllib2 as follows:</p>
  
  <pre><code>    from lxml import html
      from urllib import urlopen
  
      url = 'http://www.blahblah.com'
      good_data = False
      while good_data ==False:
          try:
              data = html.fromstring(html.tostring(html.parse(urlopen(url))))
              good_data=True
          except Exception:
              good_data=False
              print 'scraping failed'
              winsound.Beep(800,1000)
              time.sleep(pause)
  </code></pre>
  
  <p>but now I get back the error</p>
  
  <pre><code>"TypeError: expected string or buffer".
  </code></pre>
  
  <p>This happens whether I scrape from http or <a href="https://www.blahblah.com" rel="nofollow noreferrer">https://www.blahblah.com</a>.</p>
  
  <p>Either a fix for the original issue or a fix for the fix for the original issue would be much appreciated.</p>