0

I've spent a few hours too much today trying to get Python requests + hyper working.

I've managed to log onto the drupal site (need to automate some things), but it seems that due to HTTP2 only used on the server, and hyper not being at mature level - it simply does not work.

First request (loging in) works fine, but session variable remains empty, and every subsequent request fails.

I'm reading my payload from Yaml, and as mentioned, logging in and first request works fine.

payloadadmin:
  form_id : "user_login"
  name : "Igor"
  pass : "blah"
  remember_me : "1"
  op: "Log in"

def site_login():
   s = requests.session()
   s.mount('https://my.site.com', HTTP20Adapter())
   headers = {'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36    (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36'}
   r = s.post(URL, headers=headers, data=payload, allow_redirects=False, verify=True)
   return s

main:
s = site_login(conf['payloadadmin'],'https://my.site.com/user')
r = s.get('https://my.site.com/admin/export/csv')
Balkyto
  • 1,460
  • 4
  • 22
  • 47
  • did you see https://github.com/python-hyper/hyper/issues/392? – Sam Mason Jul 25 '19 at 17:08
  • That's the only one I did not see, I saw two other - somewhat similar tickets, but thought maybe there's a workaround. Not necessarily using Hyper... – Balkyto Jul 26 '19 at 07:16
  • there are a few forks that alter `contrib.py`, but hyper looks abandoned at the moment.. no commits for almost two years isn't a good sign. not sure what to suggest as it's a pretty commonly used package (I've got it in a few code bases, but didn't realise it was in this state) – Sam Mason Jul 26 '19 at 07:55
  • I'm quite surprised that there's not a single such item on the web... I mean, one would expect HTTP/2 site with sessions and python automation being used... – Balkyto Jul 26 '19 at 11:02
  • yup, note sure what's going on... https://github.com/python-hyper/hyper/issues/415 seems relevant, I've had a few interactions with njsmith before and he seems to know his stuff but is generally pretty busy. don't know the others – Sam Mason Jul 26 '19 at 11:21

0 Answers0