티스토리 뷰
1. Python to MySQL via PHP
2. MySQL to Python via PHP
1-1. Python source
def Test41():
ServerURL = "https://www.bilientsvc.net/ZezoUP/Test/ArticleCollector07.php"
REQUESTHEADER = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246"}
data11 = {
'k11': 'v11',
'k12': 'v12'
}
data1 = {
'RequestType': 'Test11',
'UserAddress': 'User11',
'Keyword': json.dumps(data11)
}
res1 = requests.post(ServerURL, headers=REQUESTHEADER, data=data1)
print(res1)
print(res1.text)
#collectionList = res1.json()
1-2. PHP source
function Test_11($conn){
$userAddress = $_POST['UserAddress'];
$keyWord = addslashes($_POST['Keyword']);
//echo $keyWord;
$Query1 = "insert into CollectionInfos(Useraddress, Keyword) values('".$userAddress."', '".$keyWord."');";
echo $Query1;
mysqli_query($conn, $Query1);
}
2-1. PHP source
function Test_12($conn){
$userAddress = $_POST['UserAddress'];
$keyWord = stripslashes($_POST['Keyword']);
$Query1 = "select * from CollectionInfos WHERE UserAddress='User11'";
$QueryResults = mysqli_query($conn, $Query1);
$QueryResultNumber = mysqli_num_rows($QueryResults);
if($QueryResultNumber < 1) return NULL;
$CIs1 = array();
$Index1 = 0;
while($Row1 = mysqli_fetch_array($QueryResults)){
$CI1 = new cCollectionInfo();
$CI1->SetValuebyRow($Row1);
$CIs1[$Index1] = $CI1->GetJSON();
$Index1++;
//echo $Index1."<br>";
}
$rst2['Results'] = $CIs1;
if($rst2['Results'] != NULL) echo json_encode($rst2);
else echo "NULL Results<br>";
}
2-2. Python source
def Test42():
ServerURL = "https://www.bilientsvc.net/ZezoUP/Test/ArticleCollector07.php"
REQUESTHEADER = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246"}
data1 = {
'RequestType': 'Test12',
'SNo':14
}
res1 = requests.post(ServerURL, headers=REQUESTHEADER, data=data1)
json1 = json.loads(res1.text)
print(json1)
for json11 in json1['Results']:
json1a = json11['Keyword']
json1b = json.loads(json1a)
print(json1a, '-', json1b['k12'])
#print(json11['Keyword']['k12'])
#collectionList = res1.json()
반응형
'SWDesk' 카테고리의 다른 글
[인공지능 - 01] 소스 데이터 편집(1) (0) | 2021.02.21 |
---|---|
[BST] 데이터 분석 #2.1 (0) | 2021.02.14 |
Naver Cafe API 설명서 (0) | 2021.01.16 |
[Python] Example for Excel Spreadsheet (0) | 2020.12.30 |
[Python] Google & Naver-news Search + Google Spreadsheet (2) | 2020.12.27 |
반응형
250x250
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 치매방지
- 전압
- BSC
- badp
- 혁신과허들
- 오블완
- 둎
- 아두이노
- 심심풀이
- 전압전류모니터링
- Decorator
- 빌리언트
- arduino
- 배프
- 티스토리챌린지
- Innovations&Hurdles
- Hurdles
- 치매
- ServantClock
- Innovations
- 혁신
- 심심풀이치매방지기
- Innovation&Hurdles
- bilient
- DYOV
- 절연형
- image
- 허들
- Video
- 전류
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함