[CWB] Log in to cqpweb from a python script

Andrés Chandía andreschandiaf at gmail.com
Fri Jul 5 14:40:00 CEST 2024


Thanks Andrew for your information,
that was the key to accomplishing my goal
Here I attach two python scripts that I managed to generate, one for simple
query, and other for cqp syntax queries...
Thanks again!

El mié, 3 jul 2024 a las 23:15, Hardie, Andrew (<a.hardie at lancaster.ac.uk>)
escribió:

> 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
> _______________________________________________
> CWB mailing list
> CWB at sslmit.unibo.it
> http://liste.sslmit.unibo.it/mailman/listinfo/cwb
>


-- 
Andrés Chandía
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://liste.sslmit.unibo.it/pipermail/cwb/attachments/20240705/8fa36ebb/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CQPWeb simultaneus queries.7z
Type: application/x-7z-compressed
Size: 2005 bytes
Desc: not available
URL: <http://liste.sslmit.unibo.it/pipermail/cwb/attachments/20240705/8fa36ebb/attachment.bin>


More information about the CWB mailing list