[CWB] Log in to cqpweb from a python script
Hardie, Andrew
a.hardie at lancaster.ac.uk
Wed Jul 3 23:14:45 CEST 2024
You need to hit the URL
https://server.net/path/to/cqpweb/usr/useracct-act.php
with post parameters username and password. (And possibly also persist=1)
The page returned will have an accompanying cookie called CQPwebLogonToken (by default; it’s changeable in the config file). You need to catch that cookie and return it with all subsequent requests (ie queries). I’d guess this is what your attempt with the browser does that your attempt without the browser doesn’t.
(The API will make this a little easier in future by allowing the token to be returned as a parameter rather than messing with cookies, but that’s only partially developed.)
Incidentally I’ve started writing client libraries in various languages to automate the above. See https://sourceforge.net/p/cwb/code/HEAD/tree/gui/cqpweb-client/trunk/ The PHP one is furthest along, the Python one rather less so; neither is functional yet; they’ve been a non-priority because I was not hitherto aware of demand…
Best
Andrew.
From: cwb-bounces at sslmit.unibo.it <cwb-bounces at sslmit.unibo.it> On Behalf Of Andrés Chandía
Sent: Wednesday, July 3, 2024 6:24 PM
To: Open source development of the Corpus WorkBench <cwb at sslmit.unibo.it>
Subject: [CWB] Log in to cqpweb from a python script
Hi there, this is not an issue about cqpweb, it is just me asking for help...
I'm trying to develop a script to access cqpweb and launch some queries, I have a script that works, but with webbot which actually opens a browser and performs the actions. This is far from ideal because it consumes too much resources, actually, in my case, the browser crashes in the second query, I've tried many other scripts which do not open web browsers but I'm unable to even login...
So my question is if somebody has and can share a python script to log in cqpweb without opening a browser...
I attach here the successful browser opening script and the unsuccessful not browser opening attempt...
Thanks in advance...
--
Andrés Chandía
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://liste.sslmit.unibo.it/pipermail/cwb/attachments/20240703/de5780f4/attachment-0001.html>
More information about the CWB
mailing list