Not working ion Ubuntu 16.04 with Chrome Version 60.0.3112.90 (Official Build) (64-bit)

Issue #16 new
D G
created an issue

Using this code:

import re
import requests
import browsercookie as bc

get_title = lambda html: re.findall('<title>(.*?)</title>', html, flags=re.DOTALL)[0].strip()

url = 'https://bitbucket.org/'
cj = bc.chrome()
r = requests.get(url, cookies=cj)
print get_title(r.content)

I see the following output: Bitbucket | The Git solution for professional teams

I had Chrome running and was logged into bitbucket at the time.

What extra logging can I turn on to help find out what is happening?

Comments (6)

  1. Richard repo owner

    I recommend checking whether cj.cookie_files contains any cookie files - if empty then your cookie files are not in the expected location, and you need to pass the path in the constructor. If this is not empty then check whether cj.get_cookies() contains the cookies for bitbucket.

  2. D G reporter

    I wasn't able to call cj.get_cookies() as this threw an errror:

    AttributeError: CookieJar instance has no attribute 'get_cookies'

    However using :

    pprint.pprint(cj)

    I could see LOTS of cookies including several for the bitbucket domain. For example:

    Cookie(version=0, name=u'_ga', value=u'', port=None, port_specified=False, domain=u'.bitbucket.org', domain_specified=True, domain_initial_dot=True, path=u'/', path_specified=True, secure=0, expires=13213025592000000, discard=False, comment=None, comment_url=None, rest={}, rfc2109=False),

    Any ideas why it fails? Which cookies does the requests module need to login to bitbucket?

    Thanks

  3. Richard repo owner

    And you're logged in to bitbucket on Chrome? If so, not sure why it's not working.

    Actually I'm surprised Chrome 60 is still able to load cookies on Linux - the cookie encryption was changed around version 59 on Mac, which currently isn't supported and raises an exception.

  4. D G reporter

    I did some further digging using pdb. It looks as if the few cookies that I stepped through are being decrypted. So perhaps it's an issue related to the Cookie jar module and it's interaction with requests?

  5. Log in to comment