摘要:手機手機手機手機獲取獲取時間戳運算加密計算成功產品名稱店名賣家小名促銷價格原價月銷量件產地網址產品名稱副標題賣家小名促銷價格原價月銷量件網址筆記本電腦可設置頁數和商品名字需要過滑塊的私信我
import re,hashlib,requests,json5,timefrom requests.utils import dict_from_cookiejarfrom loguru import loggerappKey = '12574478'def get_sign(token, t, ___): pre_sign = token + '&' + t + '&' + appKey + '&' + ___ sign = hashlib.md5(pre_sign.encode(encoding='UTF-8')).hexdigest() return signdef get_cookies(): url = 'https://h5api.m.taobao.com/h5/mtop.alimama.union.xt.en.api.entry/1.0/?jsv=2.5.1&appKey=12574478&t=1622426487791&sign=7771a311a65bbb533c3f3d4534d50f5e&api=mtop.alimama.union.xt.en.api.entry&v=1.0&AntiCreep=true&timeout=20000&AntiFlood=true&type=jsonp&dataType=jsonp&callback=mtopjsonp2&data=%7B%22floorId%22%3A195%2C%22count%22%3A10%2C%22p4pPid%22%3A%22430748_1006%22%2C%22spm%22%3A%22a2e1u.19484427.29996459%22%2C%22app_pvid%22%3A%22201_11.11.62.22_407060_1622426486844%22%2C%22ctm%22%3A%22spm-url%3Aa231o.13503973.search.1%3Bpage_url%3Ahttps%253A%252F%252Fai.taobao.com%252Fsearch%252Findex.htm%253Fspm%253Da231o.13503973.search.1%2526key%253D%2525E4%2525B8%2525B8%2525E7%2525BE%25258E%2526pid%253Dmm_110807073_1262350149_109959000489%2526union_lens%253Drecoveryid%25253A201_11.11.62.22_399283_1622423612735%25253Bprepvid%25253A201_11.11.62.22_399283_1622423612735%22%2C%22variableMap%22%3A%22%7B%5C%22union_lens%5C%22%3A%5C%22recoveryid%3A201_11.11.62.22_399283_1622423612735%3Bprepvid%3A201_11.11.62.22_399283_1622423612735%5C%22%2C%5C%22recoveryId%5C%22%3A%5C%22201_11.11.62.22_407060_1622426486844%5C%22%7D%22%7D' headers = { 'referer': 'https://ai.taobao.com/', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36' } res = requests.get(url, headers=headers).cookies cook = dict_from_cookiejar(res) cooks = '' for i, k in cook.items(): cooks += i + '=' + k + ';' return cooksdef data(num,x): # cookie ck = get_cookies() # mm_110807073_1262350149_109959000489 data_s = '{"pNum":%s,"pSize":"60","refpid":"mm_26632258_3504122_32538762",' % num # data_tm = r'"variableMap":"{/"q/":/"手機/",/"navigator/":true,/"usertype/":/"1/",/"union_lens/":/"recoveryid:201_11.11.43.24_685807_1619341742886;prepvid:201_11.27.89.99_473565_1619342131641/",/"recoveryId/":/"201_11.186.139.24_536838_1619342621063/"}","qieId":"34374","spm":"a2e1u.19484427.29996460","app_pvid":"201_11.186.139.24_536838_1619342621063","ctm":"spm-url:a2e1u.19484427.filter.6;page_url:https%3A%2F%2Fai.taobao.com%2Fsearch%2Findex.htm%3Fkey%3D%25E4%25B8%25B8%25E7%25BE%258E%26pid%3Dmm_110807073_1262350149_109959000489%26union_lens%3Drecoveryid%253A201_11.11.43.24_685807_1619341742886%253Bprepvid%253A201_11.27.89.99_473565_1619342131641%26spm%3Da2e1u.19484427.filter.6%26usertype%3D1%26pnum%3D0"}'.replace('手機',x) data_tm=r'"variableMap":"{/"q/":/"手機/",/"navigator/":false,/"clk1/":/"25b8f4d10e5d19d5a1b4c05c0cda428b/",/"union_lens/":/"recoveryid:201_11.20.200.89_16797742_1632624677134;prepvid:201_11.20.207.176_16801805_1632625096923/",/"recoveryId/":/"201_11.175.96.106_16839576_1632632392630/"}","qieId":"36308","spm":"a2e0b.20350158.31919782","app_pvid":"201_11.175.96.106_16839576_1632632392630","ctm":"spm-url:a2e0b.20350158.31919782.1;page_url:https%3A%2F%2Fuland.taobao.com%2Fsem%2Ftbsearch%3Frefpid%3Dmm_26632258_3504122_32538762%26keyword%3Dadidas%2520yeezy%2520boost%26clk1%3D25b8f4d10e5d19d5a1b4c05c0cda428b%26upsId%3D25b8f4d10e5d19d5a1b4c05c0cda428b%26spm%3Da2e0b.20350158.31919782.1%26pid%3Dmm_26632258_3504122_32538762%26union_lens%3Drecoveryid%253A201_11.20.200.89_16797742_1632624677134%253Bprepvid%253A201_11.20.207.176_16801805_1632625096923%26pnum%3D1"}'.replace('手機',x) data_s = data_s + data_tm # 獲取token token = re.findall(r"_m_h5_tk=(.*?);", ck) token = ''.join([i.split("_")[0] for i in token]) # 獲取時間戳 date = int(time.time() * 1000) # 運算sign加密 cx = get_sign(token, str(date), data_s) logger.debug("|sign計算成功>>>>%s|" % cx) headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36", "cookie": ck} data_a = { 'jsv': '2.5.1', 'appKey': '12574478', 't': date, 'sign': cx, 'api': 'mtop.alimama.union.xt.en.api.entry', 'v': '1.0', 'AntiCreep': 'true', 'timeout': '20000', 'AntiFlood': 'true', 'type': 'jsonp', 'dataType': 'jsonp', 'callback': 'mtopjsonp2', 'data': data_s } return headers, data_adef run(num,word): for page in range(num): headers, data_s = data(page,word) # data_s={"pNum":2,"pSize":"60","refpid":"mm_26632258_3504122_32538762","variableMap":"{/"q/":/"adidas yeezy boost/",/"navigator/":false,/"clk1/":/"25b8f4d10e5d19d5a1b4c05c0cda428b/",/"union_lens/":/"recoveryid:201_11.20.200.89_16797742_1632624677134;prepvid:201_11.20.207.176_16801805_1632625096923/",/"recoveryId/":/"201_11.0.174.53_16801750_1632625790037/"}","qieId":"36308","spm":"a2e0b.20350158.31919782","app_pvid":"201_11.0.174.53_16801750_1632625790037","ctm":"spm-url:a2e0b.20350158.search.1;page_url:https%3A%2F%2Fuland.taobao.com%2Fsem%2Ftbsearch%3Frefpid%3Dmm_26632258_3504122_32538762%26keyword%3Dadidas%2520yeezy%2520boost%26clk1%3D25b8f4d10e5d19d5a1b4c05c0cda428b%26upsId%3D25b8f4d10e5d19d5a1b4c05c0cda428b%26spm%3Da2e0b.20350158.search.1%26pid%3Dmm_26632258_3504122_32538762%26union_lens%3Drecoveryid%253A201_11.20.200.89_16797742_1632624677134%253Bprepvid%253A201_11.20.207.176_16801805_1632625096923"} url='https://h5api.m.taobao.com/h5/mtop.alimama.union.xt.en.api.entry/1.0/' # url = 'https://h5api.m.taobao.com/h5/mtop.alimama.union.xt.en.api.entry/1.0/' res = requests.get(url, headers=headers,params=data_s,timeout=30).content.decode('utf-8') a = json5.loads(str(res).replace('mtopjsonp2', '').replace('(', '').replace(')', '')) a = a['data']['recommend']['resultList'] for x in a: print( f"產品名稱:{x['itemName']},店名:{x['shopTitle']},賣家小名:{x['sellerNickName']},促銷價格:{x['promotionPrice']},原價:{x['price']},月銷量:{x['monthSellCount']}件,產地:{x['provcity']},網址:{x['url']}") # for x in a: # print( # f"產品名稱:{str(x['itemName']).replace('','').replace('','')}, 副標題:{x['subTitle']}, 賣家小名:{x['nick']}, 促銷價格:{x['promotionPrice']}, 原價:{x['price']}, 月銷量:{x['monthSellCount']}件, 網址:https{x['url']}, pic_url:https{x['pic']}")if '__name__'=='__main__': run(5,'筆記本電腦')#可設置頁數和商品名字
需要過滑塊的私信我!
文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。
轉載請注明本文地址:http://specialneedsforspecialkids.com/yun/121289.html
摘要:行爬取頂點全網任意小說掘金之前連續多篇文章介紹客戶端爬取平臺,今天我們從零開始,實現爬取頂點小說網任意一本小說的功能。文件標記所有文件我的后端書架后端掘金我的后端書架月前本書架主要針對后端開發與架構。 30行js爬取頂點全網任意小說 - 掘金之前連續多篇文章介紹客戶端爬取平臺(dspider),今天我們從零開始,實現爬取頂點小說網任意一本小說的功能。 如果你還不知道客戶端爬取,可以先看...
摘要:行爬取頂點全網任意小說掘金之前連續多篇文章介紹客戶端爬取平臺,今天我們從零開始,實現爬取頂點小說網任意一本小說的功能。文件標記所有文件我的后端書架后端掘金我的后端書架月前本書架主要針對后端開發與架構。 30行js爬取頂點全網任意小說 - 掘金之前連續多篇文章介紹客戶端爬取平臺(dspider),今天我們從零開始,實現爬取頂點小說網任意一本小說的功能。 如果你還不知道客戶端爬取,可以先看...
摘要:標簽不區分大小寫,但推薦小寫。標簽可以嵌套,但不能交叉嵌套。標簽也稱為元素。比如行內標簽亦可成行內元素。 ??HTML必備知識詳解?? 第一部分:HTML框架簡介...
摘要:而調用后端服務就應用了的高級特分布式配置管理平臺后端掘金輕量的分布式配置管理平臺。關于網絡深度解讀后端掘金什么是網絡呢總的來說,網絡中的容器們可以相互通信,網絡外的又訪問不了這些容器。 在 Java 路上,我看過的一些書、源碼和框架(持續更新) - 后端 - 掘金簡書 占小狼轉載請注明原創出處,謝謝!如果讀完覺得有收獲的話,歡迎點贊加關注 物有本末,事有終始,知所先后,則近道矣 ......
閱讀 713·2023-04-25 19:43
閱讀 3910·2021-11-30 14:52
閱讀 3784·2021-11-30 14:52
閱讀 3852·2021-11-29 11:00
閱讀 3783·2021-11-29 11:00
閱讀 3869·2021-11-29 11:00
閱讀 3557·2021-11-29 11:00
閱讀 6105·2021-11-29 11:00