Show HN: HTTPLang – a scripting language for making HTTP requests
github.com
github.com
> I find the process to be stupidly complicated, and handling cookies is a nightmare.
However this is about as straightforward as it can get with Requests. This is the HTTPLang example:
set URL http://somesite.com
set POSTDATA username=myUsername,password=myPassword is this
do POST /login
set COOKIE $TMPCOOKIE
do GET /usercp
Here is the equivalent in Python using Requests: import requests
url = "http://example.com"
post_data = { "username": "myUsername", "password": "myPassword is this" }
response = requests.post(url + "/login", data=post_data)
cookies = response.cookies
requests.get(url + "/usercp", cookies=cookies)
Where's the stupidly complicated nightmare?The only complicated things I see above are in the HTTPLang version: a variable called "URL" that isn't actually the URL that is being requested, and I guessed at how the cookie functionality worked because it's not at all obvious – I'm assuming that `set COOKIE $TMPCOOKIE` gets the cookie from the previous request and sets it for the subsequent requests.