Code Monkey home page Code Monkey logo

easy-http-request's Introduction

Hi, welcome to my Github pages.

Things Related to My Projects

Rust JavaScript TypeScript Java C PHP Golang Bash

Ubuntu Server Linux Mint Android Windows

Tokio Rocket Axum napi-rs iced Node.js Webpack Express Fastify NestJS + Fastify Bootstrap Vite Vue.js Handlebars Tera Sass Nginx Apache httpd Docker

MySQL SQLite MongoDB Redis

easy-http-request's People

Contributors

magiclen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

easy-http-request's Issues

Please provide a post example with headers and json body

please provide a post example with headers and json body.
I am not able to find any examples.

Below code in python, I want to convert it to rust with using openssl.

import requests
import json

login_url = "https://ant.aliceblueonline.com/api/v2/login"
twofa_url = "https://ant.aliceblueonline.com/api/v2/checktwofa"
s = requests.Session()

secret = json.loads(open('secret.json', 'r').read().rstrip())

# NOTE contents of secret.json must be like below
# {
#     "login_id":"AB123456",
#     "password":"PaSSw0rd@1",
#     "twofa":"a"
# }

login_json = {"device": "web"}
login_json['login_id'] = secret['login_id']
login_json['password'] = secret['password']

r = s.post(login_url, json=login_json)

twofa_json = {"device": "web", "count": 2}
twofa_json['login_id'] = secret['login_id']
twofa_json['answers'] = [secret['twofa'], secret['twofa']]
twofa_json['question_ids'] = r.json()['data']['question_ids']

r = s.post(twofa_url, json=twofa_json)

with open('access_token.txt', 'w') as wr:
    wr.write(r.json()['data']['auth_token'])

print(open('access_token.txt', 'r').read().rstrip())

I want to do exactly the above stuff but without using reqwest module.
Thanks for helping out.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.