try to fix login by formatting the form correctly
This commit is contained in:
parent
8c4b525cbf
commit
bdcfead62c
14
webcrawler
14
webcrawler
|
@ -86,12 +86,16 @@
|
||||||
|
|
||||||
;; Logs in with the given username and password
|
;; Logs in with the given username and password
|
||||||
(define (crawler-login username password)
|
(define (crawler-login username password)
|
||||||
|
(void (crawler-fetch 'POST LOGIN-PATH
|
||||||
|
(form-alist->http-body
|
||||||
|
`([username . ,username]
|
||||||
|
[password . ,password]
|
||||||
|
[csrfmiddlewaretoken . ,(crawler-get-csrf-token!)])))))
|
||||||
|
|
||||||
|
;; -> string?
|
||||||
|
(define (crawler-get-csrf-token!)
|
||||||
(crawler-fetch 'GET LOGIN-PATH)
|
(crawler-fetch 'GET LOGIN-PATH)
|
||||||
(define form-body
|
(cookie-jar-ref (current-cookie-jar) "csrftoken"))
|
||||||
(format "username=~a&password=~a&csrfmiddlewaretoken=~a&next="
|
|
||||||
username password (cookie-jar-ref (current-cookie-jar) "csrftoken")))
|
|
||||||
(crawler-fetch 'POST LOGIN-PATH (string->bytes/utf-8 form-body))
|
|
||||||
(void))
|
|
||||||
|
|
||||||
;; Checks if this is a URL we should crawl
|
;; Checks if this is a URL we should crawl
|
||||||
(define (crawler-valid-url? page-url)
|
(define (crawler-valid-url? page-url)
|
||||||
|
|
Loading…
Reference in New Issue