title: pyCurl and BytesIO for scraping a website
body: <p>I would have a need for scraping. Specifically, I use Pycurl and BytesIO.</p>
  <p>The following code:</p>
  <pre><code>c = pycurl.Curl()
  page = BytesIO()
  c.setopt(c.INTERFACE, &quot;tun0&quot;)
  c.setopt(c.USERAGENT, userAgent)
  c.setopt(pycurl.CAINFO, certifi.where())
  c.setopt(c.URL, URL)
  c.setopt(c.WRITEDATA, page)
  c.perform()
  </code></pre>
  <p>Until yesterday, <code>page.getvalue()</code> would return the html of the page which I would then pass to bs4. Today, however, I notice that it returns a string in bytes that I can't even decode into utf-8 because it returns an error:</p>
  <pre><code>UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
  </code></pre>
  <p>How can I get in the string type the content of the url, in order to pass it to bs4 and scrape?</p>