Get the App
SLTechnology News&Howtos  ›  Servers  › 

Example Analysis of making Wheel with React.js+Egg.js

Shulou Source: shulou.com Published: 2022-05-31 20:02:01 09月28日 Update

In this issue, the editor will bring you an example analysis of making wheels with React.js+Egg.js. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

Download: use React.js+Egg.js to build wheels

The script is as follows:

1. Introduce the required third-party package

#! / usr/bin/env python3 #-*-coding: utf-8-*-import requests # import reimport json # from bs4 import BeautifulSoup

two。 Set the request header and set the request parameters. You need to convert the Python dictionary to json string.

Url = 'http://beanhome.com/user/login'header = {"Content-Type":' application/json', "User-Agent": "Mozilla/5.0 (Macintosh) Intel Mac OS X 10: 14: 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.87 Safari/537.36 "} # Python dictionary data into json, you need to use json.dumpsdata = {" email ":" common@moviebook.com "," passwd ":" 123456 "} # simulated login through session, each request with sessionsess = requests.Session () f = sess.post (url, data=json.dumps (data), headers=header)

3. Print the result after a successful login

Print (json.loads (f.text)) # soup = BeautifulSoup (f.content, "html.parser") # {'status': 1,' msg': 'operation succeeded,' time': 1565317698, 'element': {' id': 1, 'uid': 1,' name': 'common',' email': 'common@moviebook.com',' company':', 'type': 1' 'title':' ordinary user'}}

4. Print menu results

Url = 'http://beanhome.com/user/getMenu'# get menu f = sess.post (url,headers=header) print (json.loads (f.text))

5. Print configuration option results

# get the configuration option url= 'http://beanhome.com/user/getOptionList'result = sess.post (url, headers=header) # print (json.loads (result.text)) for JMagol k in json.loads (result.text) [' element'] .items (): print (JMagre k)

The above is the example of using React.js+Egg.js to build wheels that Xiaobian shared with you. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Tags: Analysis wheels results examples success content dictionary menu login configuration normal professional small and medium-sized company rich content parameters characters strings customers that is Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Microsoft Redmi Apple NVidia