Answer the question
In order to leave comments, you need to log in
I can't get a JSON response from the site via python script?
Good afternoon!
Faced such a problem, there is a mailer on Roundcube, which I access through the Web face and try to download mail using a Python script.
There is a URL (example): mail.mail.com/?_task=mail&_action=list&_mbox=INBOX...
When accessed on other Roundcube servers, I get a dictionary in response:
{"action":"list","unlock":"loading1527827018822","env":{"mailbox":"INBOX","pagesize":50,"current_page":1,"delimiter":".","threading":false,"threads":true,"reply_all_mode":0,"layout":"list","drafts_mailbox":"Drafts","trash_mailbox":"Trash","junk_mailbox":"Junk","read_when_deleted":true,"display_next":true,"messagecount":146,"pagecount":3,"exists":146,"multifolder_listing":false},"exec":"this.set_pagetitle(\"MAI MAIL.COM");\nthis.set_unread_count(\"INBOX\",0,true,\"\");\nthis.set_rowcount(\"blabla 146\",\"INBOX\");\nthis.set_message_coltypes([\"threads\",\"subject\",\"status\",\"fromto\",\"date\",\"size\",\"flag\",\"attachment\"],null,\"from\");\nthis.add_message_row(147,{\"subject\
responseData = session.get("http://www.mail.mail.com/?_task=mail&_action=list&_refresh=1&_mbox=" + remote + "&_page=1&_remote=1&_unlock=loading" + unix_time_conv("UniTodey") + "&_=" + unix_time_conv(3) + "", cookies=responseAuth.cookies.get_dict(), headers=headers, proxies=proxies)
print(responseData.json())
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Answer the question
In order to leave comments, you need to log in
When you open the url in a browser, RoundCube understands that you are authorized by looking at the request headers (I don't know what exactly RoundCube is using, perhaps a cookie or a parameter in the URL).
If you need to open a url from Python, then most likely you first need to perform an authentication request or pass an API key in the request (again, you need to look at the RoundCube documentation).
It is also worth making sure that all request headers from Python match the headers transmitted by the browser (for example, header Accept
).
Well, there is a ready-made API, why all these perversions?
https://github.com/roundcube/roundcubemail/wiki/Pl...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question