当前位置:网站首页>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 边栏推荐
- WordPress pill applet build applet from zero to one [pagoda panel environment installation]
- Spirit information development log (1)
- Excellent tech sharing | research and application of Tencent excellent map in weak surveillance target location
- 目标5000万日活,Pwnk欲打造下一代年轻人的“迪士尼乐园”
- On BOM and DOM (4): dom0/dom2 event handling analysis
- Asp+access web server reports an error CONN.ASP error 80004005
- 基于三维GIS系统的智慧水库管理应用
- Nature Neuroscience: challenges and future directions of functional brain tissue characterization
- Analysis and treatment of easydss flash back caused by system time
- Game website making tutorial and correct view of games
猜你喜欢
随机推荐
WordPress pill applet build applet from zero to one [wordpress pagoda configure SSL pseudo static]
The gadgets developed by freshmen are popular. Netizen: my food is good
Flutter environment installation & operation
How does go limit the flow of services?
记录--关于virtual studio2017添加报表控件的方法--Reportview控件
go 断点续传
Tencent cloud VPC machine, no image when installing monitoring components
On BOM and DOM (1): overview of BOM and DOM
How accurate are the two common methods of domain name IP query
Go current limiting component package rate source code analysis
Tencent Security jointly established a data security committee
How to batch move topics to different categories in discover
Fault analysis | using --force to batch import data leads to partial data loss
Do you want to research programming? I got six!
Produce kubeconfig with permission control
What is Druid
In the half year, there were 2.14 million paying users, a year-on-year increase of 62.5%, and New Oriental online launched its private domain
Easynvr is optimized when a large number of videos are not online or unstable due to streaming failure
About Stacked Generalization
Analysis on the influence of "network security policy issued successively" on Enterprises



![Command ‘[‘where‘, ‘cl‘]‘ returned non-zero exit status 1.](/img/2c/d04f5dfbacb62de9cf673359791aa9.png)





