当前位置:网站首页>Project demo
Project demo
2022-06-24 06:41:00 【_ Chengxuyuan_】
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>json Analog data </title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
.container {
width: 800px;
margin: 200px auto;
padding: 30px 0;
border: 1px dashed #272627;
}
.test {
width: 100%;
padding: 10px 0;
margin: 20px 0;
color: #4bade8;
font-size: 18px;
text-align: center;
}
#jsonList {
width: 500px;
margin: 0 auto;
}
#jsonTable th,
td {
padding: 6px 0;
line-height: 30px;
text-align: center;
}
</style>
</head>
<body>
<div class="container">
Inquire about :<input id="shoppname">
<button onclick="getAir()"> Start </button>
<div class="test"> City information data </div>
<table border="1" cellspacing="0" bordercolor="#4bade8" cellpadding="0" id="jsonList">
<tr>
<th> Commodity images </th>
<th> title </th>
<th> sales </th>
<th> Price </th>
</tr>
</table>
</div>
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
});
function getAir() {
var temp = '';
var shoppname = $("#shoppname")
$.ajax({
type: "get",
url: "http://127.0.0.1:8888/login?name="+shoppname.val(),
crossDomain:true,
withCredentials: true,
dataType: "json",
success: function(res) {
var list = res.air;
console.log(list);
for(var $i = 0; $i < list.length; $i++) {
temp +=
'<tr>' +
'<td><img src=https://img10.360buyimg.com/n7/'+ list[$i].image_url+'></td>'+
'<td>' + list[$i].ad_title + '</td>' +
'<td>' + list[$i].ad_title + '</td>' +
'<td>' + list[$i].fuzzy_comment_num + '</td>' +
'<td>' + list[$i].pc_price + '</td>' +
'</tr>';
}
$("#jsonList tr:not(:first)").html("");
$("#jsonList").append(temp);
}
});
}
</script>
</body>
</html>
# This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
import requests
import flask, json
from flask import request
from functools import wraps
from flask import make_response
# Create a service , Put the current one python File as a service
from flask_cors import *
server = flask.Flask(__name__)
CORS(server, supports_credentials=True)
headers = {
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36', 'Cookie': 'shshshfpa=5719f356-617a-a963-c125-b68ffb376a27-1655426903; shshshfpb=mc6Ix2qAeARfFCYp97pfRgg; __jdu=522058129; areaId=20; ipLoc-djd=20-1715-0-0; unpl=JF8EAKtnNSttW0wHDB0EGBsVQ14DW19dHB8AZ2AMBg5QTFQGTFUcFxd7XlVdXhRKEB9vYRRVVVNIUQ4bCysSEXteXVdZDEsWC2tXVgQFDQ8VXURJQlZAFDNVCV9dSRZRZjJWBFtdT1xWSAYYRRMfDlAKDlhCR1FpMjVkXlh7VAQrBhgREU9UVF1VOHsQM19XAlxUUUpkBCsDK1BEF15XWFsOBhMAbGYBXV1bQ2QEKwE; __jdv=76161171|baidu-pinzhuan|t_288551095_baidupinzhuan|cpc|0f3d30c8dba7459bb52f2eb5eba8ac7d_0_26b87728492f43df92968cb9612ff646|1655428913944; __jda=122270672.522058129.1655426897.1655426914.1655428914.2; __jdc=122270672; shshshfp=5daf55a5f6651ee4daeaeb350d688ac1; _gia_s_local_fingerprint=694e91f20a9c0034add669b38a1635be; mba_muid=522058129; wlfstk_smdl=9mxgmgoabz90ko50ikngzjv2ijvmiyds; ip_cityCode=1715; 3AB9D23F7A4B3C9B=WC647EA3LN4QKED7CK6UDPBV52MLI4PNMGDKRIHXZPKU3FBSIXYEEBOMEYKNWT2GWONSSZJ4PVXXXSXYNB5WC6DXPQ', } # server.route() You can turn a normal function into a service The path to the login interface 、 Request mode @server.route('/login', methods=['get', 'post']) def login(): # Get through url Data requested for parameter transmission username = request.values.get('name') print(username+" Pass on ") url = 'https://search-x.jd.com/Search?callback=jQuery3783932&area=50&enc=utf-8&keyword=+' + username + '+&adType=7&page=1&ad_ids=291%3A33&xtest=new_search&_=1655429655358' resp = requests.get(url, headers=headers) respjson = resp.text.split("jQuery3783932(")[1] respjson1 = respjson[0:len(respjson) - 1] print(respjson1) test = json.loads(respjson1.replace('291', 'air', 1)) # json_data = resp.json(test) resu = test return json.dumps(resu, ensure_ascii=False) # Convert the dictionary to json strand , json Is string # # https://cd.jd.com/description/channel?skuId=10025631728908&mainSkuId=100029662616&charset=utf-8&cdn=2&callback=showdesc def allow_cross_domain(fun): @wraps(fun) def wrapper_fun(*args, **kwargs): rst = make_response(fun(*args, **kwargs)) rst.headers['Access-Control-Allow-Origin'] = '*' rst.headers['Access-Control-Allow-Methods'] = 'PUT,GET,POST,DELETE' allow_headers = "Referer,Accept,Origin,User-Agent" rst.headers['Access-Control-Allow-Headers'] = allow_headers return rst return wrapper_fun if __name__ == '__main__': server.run(debug=True, port=8888, host='0.0.0.0') # Designated port ,host,0.0.0.0 It means no matter how many network cards , whatever ip All accessible 边栏推荐
- Command ‘[‘where‘, ‘cl‘]‘ returned non-zero exit status 1.
- Forbid viewing source code in web page (protect source code)
- Manual for automatic testing and learning of anti stepping pits, one for each tester
- Papamelon 11 number of calculation permutation [combinatorics]
- Surveying and mapping principle of GIS coordinate system: geoid / datum / reference ellipsoid /epsg/sri/wkt
- Nine possibilities of high CPU utilization
- Source code analysis of current limiting component uber/ratelimit
- Easyscreen live streaming component pushes RTSP streams to easydss for operation process sharing
- What are the audio formats? Can the audio format be converted
- Cloudcompare & PCL point cloud clipping (based on clipping box)
猜你喜欢
随机推荐
Record of waic 2021 round table conference 𞓜 cross border dialogue: current situation and future of AI and sustainable development
Architecture: rest and HATEOAS
The three-year action plan of the Ministry of industry and information technology has been announced, and the security industry has ushered in major development opportunities!
How to open a hidden file
On BOM and DOM (6): bit value calculation of DOM objects and event objects, such as offsetx/top and clearx
Easynvr is optimized when a large number of videos are not online or unstable due to streaming failure
What are the audio formats? Can the audio format be converted
Manual for automatic testing and learning of anti stepping pits, one for each tester
How to solve the problem that after Tencent cloud sets static DNS, restarting the machine becomes dynamic DNS acquisition
【二叉数学习】—— 树的介绍
"Adobe international certification" design white must understand the color theory, absolutely full of dry goods
Implementation of code rate and frame rate statistics in easyplayer RTSP player
Oceanus kudu sink summary
Flexible use of distributed locks to solve the problem of repeated data insertion
About Stacked Generalization
puzzle(019.1)Hook、Gear
Tencent cloud VPC machine, no image when installing monitoring components
Web address domain name IP query method, what is the use of domain name
学生管理系统页面跳转及数据库连接
SQL server memory management on cloud








