python_apps/crwlers/enuri_price_get.py
2023-11-03 14:49:12 +09:00

84 lines
2.4 KiB
Python

import requests, bs4, urllib, sys, re, json, random
term = str(sys.argv[1]);
query = urllib.parse.quote_plus(term)
url = "http://www.enuri.com/lsv2016/ajax/getSearchGoods_ajax.jsp"
data = {
'key': 'popular DESC',
'random_seq': random.randint(1, 1000),
'pageNum': '1',
'pageGap': '90',
'tabType': '1',
'cate': '',
'IsDeliverySumPrice': 'N',
'keyword': term,
'in_keyword': '',
'IsJungoPriceRemove': 'N',
'm_price': '',
'start_price': '',
'end_price': ''
}
headers = {
'authority': 'www.enuri.com',
'Referer': 'http://www.enuri.com/search.jsp?nosearchkeyword=&issearchsearchkind=&es=&c=&ismodelno=false&hyphen_2=false&from=&owd=&keyword=' + query + '&tabType=1',
'accept': 'application/json, text/javascript, */*; q=0.01',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36',
'Accept-Encoding': 'gzip, deflate, br'
}
resp = requests.get(url, params = data, headers = headers)
resp.raise_for_status()
resp.encoding='UTF-8'
data = json.loads(resp.content)
def displayText ( plist ) :
res = '['
for i in range(len(plist)) :
optText = plist[i]['strBeginnerDicCondiname']
pricText = plist[i]['strGoodsGroupMinPrice']
mallCT = plist[i]['intMallcnt']
res = res + "{'" + optText + "','" + pricText + "','" + mallCT + "'}"
if i != (len(plist) - 1) : res = res + ','
res = res + ']'
return res
nrCheck = data['intTotRsCnt']
if nrCheck == '0' :
print(term + "\t" + "Not Found")
else :
rank = 1
res_count = data['intEnuriCnt']
_lists = data['srpModelList']
for i in range(len(_lists)) :
productName = _lists[i]['strModelName']
priceText = _lists[i]['lngMinPrice']
categoryText = ''
reviewCountsText = _lists[i]['kbnum']
regDateText = _lists[i]['strCdate']
sellingItemCount = ''
mallCounts = _lists[i]['intMallCnt']
mallsContent = ''
linkStr = 'http://www.enuri.com/detail.jsp?modelno=' + _lists[i]['intModelNo'] + '&cate=&IsDeliverySum=N'
enrSortCount = _lists[i]['groupModelCnt']
displayText_ = displayText(_lists[i]['groupModelList'])
print(
term + "\t" +
res_count + "\t" +
str(rank) + "\t" +
productName + "\t" +
priceText + "\t" +
categoryText + "\t" +
reviewCountsText + "\t" +
regDateText + "\t" +
sellingItemCount + "\t" +
mallCounts+ "\t" +
mallsContent + "\t" +
linkStr + "\t" +
enrSortCount + "\t" +
displayText_
)
rank = rank + 1