chiark / gitweb /
First working grok function-- login1
authorMarnanel Thurman <marnanel@thurman.org.uk>
Sat, 27 Nov 2021 18:11:51 +0000 (18:11 +0000)
committerMarnanel Thurman <marnanel@thurman.org.uk>
Sat, 27 Nov 2021 18:11:51 +0000 (18:11 +0000)
src/grok.js

index d9b5f9fd476dc69ac47c48513e1b20b94f0f0abe..bb4aefbb384b2a96ed6ea041c36b2ede182c126a 100644 (file)
@@ -8,15 +8,23 @@ export function grok_login1() {
                 {},
                 {},
                 function(response) {
-                        console.log(response.status);
-                        console.log(response.data);
                         var soup = new JSSoup(response.data);
-                        var tag = soup.find('head');
-                        console.log(tag)
+
+                        // jssoup apparently doesn't let you search
+                        // by id at present
+                        for (var tag of soup.findAll('input')) {
+                                if (tag.attrs.name=='lj_form_auth') {
+                                        result['auth'] = tag.attrs.value;
+                                        break;
+                                }
+                        }
+
+                        result['success'] = true;
 
                 },
                 function(response) {
-                        console.error(response.error);
+                        result['success'] = false;
+                        result['message'] = response.error;
                 });
 
         return result;