首页 > 其他分享 >walmart商品数据及评论数据获取

walmart商品数据及评论数据获取

时间:2022-12-17 10:57:33浏览次数:44  
标签:comment headers url text self 获取 walmart 数据 page

打开产品页,爬取商品数据及评论数据

# -*- coding: utf-8 -*-
"""====================================================================================================================
@function : 沃尔玛部分商品数据及评论
==================================================================================================================="""

import math
import random
import re
import time
import json

import requests
from loguru import logger
from bs4 import BeautifulSoup
from concurrent.futures import ThreadPoolExecutor

from utils.request import Request
from utils.common import sleep2, open_gsheet, gsheet_append_rows, gsheet_append_row


class Walmart:
def __init__(self):
self.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',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'zh-CN,zh;q=0.9',
# 'cookie': '_pxhd=d72621e2b07c28a1f2429308c9da062a968286848d7a67d48b826e44e9f57c16:6ef3bd8c-6be6-11ed-b9df-54655163516d; ACID=e598249c-061a-4b4c-9eb8-1106ce5ba705; hasACID=true; assortmentStoreId=3081; hasLocData=1; TB_Latency_Tracker_100=1; TB_Navigation_Preload_01=1; TB_SFOU-100=; vtc=Y--TgPPEE7yosKPSHqcBes; adblocked=false; _pxvid=6ef3bd8c-6be6-11ed-b9df-54655163516d; TBV=7; ak_bmsc=3F7F036150778BD906468CC9836379D7~000000000000000000000000000000~YAAQBy83FzZYmpmEAQAAbzrQrREG5O1z+AfnAjy9/8NaZqmc2sN3oWIvWywKiAF335MOHeSur/YvnAVX3IzdlPtYQxP9E/BtdDaqn8yUeTWJcmzKYJRhw+OG7G3hPWOl0GZnLGEhfRcgVUZH9aNivpx/odY5kvN8yuCWUkBmBbRohk6htm5dr2xHY0vYS+7INUTePlosFTYlqxHnZTQ8IaIn6gQ3ELJ6JAvCd2uXSJ++tNIQv80l52lAgI8FW/XMgeWvMMSlw7Jh+DuVr8WxTVw7cD5eoizif0WVjHfCnDrkEYQEwpT9xvR0V0KcXqfYgj0JVk86oEvpbz/yXBk07SHxcEclLkQ2GZCV5BH4/cycC6sQt8KtqYPWkN7w6dOtxzE8fAYqi7gQcoeXOTlex68Hxy4R2ucb34dosNUQfqQvaCcE+ZsZXgclKy+k36zsDH8uDCvsLK9MCFW6FOVFW5zQaxTxlEf+PXUpMTr9dy0RJlAtfj09rwGJKfsO; AID=wmlspartner%3D0%3Areflectorid%3D0000000000000000000000%3Alastupd%3D1669363454690; SSP_AB_876878678=variant4; _sp_id.ad94=8d0a7c17-fbf8-467d-a9ba-4bb84c5d8b15.1669363456.1.1669363457.1669363456.57b5107c-5e00-4236-8521-e609c3a088c9; auth=MTAyOTYyMDE4sOs7grBquFdCsQ1KdvDrcOTmXMug5%2BkjMP9IqpTgOi9c0USZNbwUpRiFfzabmHV7cLjt3a6BLA1dQYOlV1UE3HG0Bu%2FjqjIgY24l%2FLCnfnKtCSg6tOwIrOJWz9pbPVRa767wuZloTfhm7Wk2KcjygglTqinKgSpV0hco0QKmh1CAigaMdpoVcnngFCXLA4W3CVzjPiulKykwUVaGCPu68lQQad6werBfNn3EPlJLUZMUMk70P8glgOEpLOprhDfMM%2FFHGZ2dCNmxWrdkwqEKrmM4g2ZwETkJBXsO4XI7ngKvEWLkn%2BsZkFImeMkZQ2wNxjrRXBn%2FYaysjpT8fbqa71ElzYH5XGp66ajg5XBJ9yHJPa8XnPZpaj74sesKFnw3G9%2FsQOyCpo2g3hWHrfWiO5E5WBBdZBCyKnCQAR7o6eg%3D; bstc=U3RhyBFrPyfYiLFZAeHlFw; mobileweb=0; xptc=assortmentStoreId%2B3081; xpth=x-o-mverified%2Bfalse; xpa=; xpm=3%2B1669367780%2BY--TgPPEE7yosKPSHqcBes~%2B0; xptwj=rq:df473d75ec6d508af5e4:iFWmVk4rGz4HpXMQNtyRKRNv9mHbgiU0omZCUt206o+q76hwAUNtCT5Bk3iKPWty3FOFwQX2ddBTpXArrtrSPrUTqfxizaGsb4QcyOyd4WakTvMS6njx6iF/6Ic=; akavpau_p2=1669368382~id=ac082d35ca28c6ad1ebc826e1cdfc8a1; _astc=0c9c838905902e12f12b6ed908078e67; pxcts=d4d3d132-6ca1-11ed-acc7-56564173716f; _pxff_cfp=1; com.wm.reflector="reflectorid:0000000000000000000000@lastupd:1669367783000@firstcreate:1669363411941"; locGuestData=eyJpbnRlbnQiOiJTSElQUElORyIsImlzRXhwbGljaXQiOmZhbHNlLCJzdG9yZUludGVudCI6IlBJQ0tVUCIsIm1lcmdlRmxhZyI6ZmFsc2UsImlzRGVmYXVsdGVkIjp0cnVlLCJzdG9yZVNlbGVjdGlvblR5cGUiOiJERUZBVUxURUQiLCJwaWNrdXAiOnsibm9kZUlkIjoiMzA4MSIsInRpbWVzdGFtcCI6MTY2OTM2MzQxMTk3Nn0sInNoaXBwaW5nQWRkcmVzcyI6eyJpZCI6bnVsbCwidGltZXN0YW1wIjoxNjY5MzYzNDExOTc2LCJjcmVhdGVUaW1lc3RhbXAiOm51bGwsInR5cGUiOiJwYXJ0aWFsLWxvY2F0aW9uIiwiZ2lmdEFkZHJlc3MiOmZhbHNlLCJwb3N0YWxDb2RlIjoiOTU4MjkiLCJjaXR5IjoiU2FjcmFtZW50byIsInN0YXRlIjoiQ0EiLCJkZWxpdmVyeVN0b3JlTGlzdCI6W3sibm9kZUlkIjoiMzA4MSIsInR5cGUiOiJERUxJVkVSWSJ9XX0sInBvc3RhbENvZGUiOnsidGltZXN0YW1wIjoxNjY5MzYzNDExOTc2LCJiYXNlIjoiOTU4MjkifSwibXAiOltdLCJ2YWxpZGF0ZUtleSI6InByb2Q6djI6ZTU5ODI0OWMtMDYxYS00YjRjLTllYjgtMTEwNmNlNWJhNzA1In0%3D; locDataV3=eyJpc0RlZmF1bHRlZCI6dHJ1ZSwiaXNFeHBsaWNpdCI6ZmFsc2UsImludGVudCI6IlNISVBQSU5HIiwicGlja3VwIjpbeyJidUlkIjoiMCIsIm5vZGVJZCI6IjMwODEiLCJkaXNwbGF5TmFtZSI6IlNhY3JhbWVudG8gU3VwZ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lcmNlbnRlciIsIm5vZGVUeXBlIjoiU1RPUkUiLCJhZGRyZXNzIjp7InBvc3RhbENvZGUiOiI5NTgyOSIsImFkZHJlc3NMaW5lMSI6Ijg5MTUgR2VyYmVyIFJvYWQiLCJjaXR5IjoiU2FjcmFtZW50byIsInN0YXRlIjoiQ0EiLCJjb3VudHJ5IjoiVVMiLCJwb3N0YWxDb2RlOSI6Ijk1ODI5LTAwMDAifSwiZ2VvUG9pbnQiOnsibGF0aXR1ZGUiOjM4LjQ4MjY3NywibG9uZ2l0dWRlIjotMTIxLjM2OTAyNn0sImlzR2xhc3NFbmFibGVkIjp0cnVlLCJzY2hlZHVsZWRFbmFibGVkIjp0cnVlLCJ1blNjaGVkdWxlZEVuYWJsZWQiOnRydWUsImFjY2Vzc1BvaW50cyI6W3siYWNjZXNzVHlwZSI6IkRFTElWRVJZX0FERFJFU1MifV0sImh1Yk5vZGVJZCI6IjMwODEiLCJpc0V4cHJlc3NEZWxpdmVyeU9ubHkiOmZhbHNlLCJzdXBwb3J0ZWRBY2Nlc3NUeXBlcyI6WyJERUxJVkVSWV9BRERSRVNTIl19LCJpbnN0b3JlIjpmYWxzZSwicmVmcmVzaEF0IjoxNjY5Mzg5MzgzOTExLCJ2YWxpZGF0ZUtleSI6InByb2Q6djI6ZTU5ODI0OWMtMDYxYS00YjRjLTllYjgtMTEwNmNlNWJhNzA1In0%3D; xptwg=2169576909:DB1D04C9345370:233BCB8:6478263:7F9EE5C1:7362492A:; TS012768cf=01591e720763923c39bed01a647e0fda982c328d2935f335df1eac7a0fd972bf432d48c5a6a1813506cb2d6e52492cd32c9dfc216b; TS01a90220=01591e720763923c39bed01a647e0fda982c328d2935f335df1eac7a0fd972bf432d48c5a6a1813506cb2d6e52492cd32c9dfc216b; TS2a5e0c5c027=082d796201ab200015596660cfcff74ce4b996cba42eba62a52965f23c3271534ab695174b5eadf308412f2805113000b805a5194a9b9c06b55ab4a3993b1fd9a05ae6425d806d296726b696ae3b01bf992c55e7802490f2c16ef84652b96721; bm_sv=3FE8982CCC490CF78C9A74355098563E~YAAQH/h335ftrnyEAQAAV+ISrhFM/KbRblu3Q2cMiVRhocYwPiax90x3TsOJFPfjzPF59MPL/5z4THTLQHiYs8WOZhqqDa+NT8nxVgtlziPv1Qx70gA0XwF6reBgUrCS0zjZ1d4hHzLmDcaK/QPVhbFfiuff0ojRVgo+DzGcf1IcDLcDmv0fWl9AK3rxvgUcHsYIYqpGIDb3ZmDy4RdyuZ/cB30dJfxqcMvRe3pEUF5cMrf/i/ixI7FUdIhUdcWNNw==~1; _px3=043f49029482625cc091affcb52483667402fd612c32b8ac046a281428f159b0:yLuQLX/vJLOeuenEN77Wrkxnn6SZmUtN+I+q+v/mnHvHPK/g4yYUxDkW0QzU9kz1Oi3RN/g86Rm4TOb0krqdRQ==:1000:BGX7gc94OnvCfd5UXRxvj6OkBghJvT0ySeIbM1rv9RAVb77npabnxZveShB8IvLnnGYFbi/7B0iMQ3lxvrEZ3JuUnSNsB96j4iYCy2XkBTLXpq7xof9O+AMtxzXWQ/HPQ8fR02OC8TJVoosvPCPobKcWqMiGNHDqe6YS7JbOF4TxupsHJJ9uuX6IS7/6shTCKFmUQQQGaU0OZyHVtfOVRg==',
'cookie':'_pxhd=d72621e2b07c28a1f2429308c9da062a968286848d7a67d48b826e44e9f57c16:6ef3bd8c-6be6-11ed-b9df-54655163516d; ACID=e598249c-061a-4b4c-9eb8-1106ce5ba705; hasACID=true; assortmentStoreId=3081; hasLocData=1; TB_Latency_Tracker_100=1; TB_Navigation_Preload_01=1; TB_SFOU-100=; vtc=Y--TgPPEE7yosKPSHqcBes; adblocked=false; _pxvid=6ef3bd8c-6be6-11ed-b9df-54655163516d; TBV=7; ak_bmsc=3F7F036150778BD906468CC9836379D7~000000000000000000000000000000~YAAQBy83FzZYmpmEAQAAbzrQrREG5O1z+AfnAjy9/8NaZqmc2sN3oWIvWywKiAF335MOHeSur/YvnAVX3IzdlPtYQxP9E/BtdDaqn8yUeTWJcmzKYJRhw+OG7G3hPWOl0GZnLGEhfRcgVUZH9aNivpx/odY5kvN8yuCWUkBmBbRohk6htm5dr2xHY0vYS+7INUTePlosFTYlqxHnZTQ8IaIn6gQ3ELJ6JAvCd2uXSJ++tNIQv80l52lAgI8FW/XMgeWvMMSlw7Jh+DuVr8WxTVw7cD5eoizif0WVjHfCnDrkEYQEwpT9xvR0V0KcXqfYgj0JVk86oEvpbz/yXBk07SHxcEclLkQ2GZCV5BH4/cycC6sQt8KtqYPWkN7w6dOtxzE8fAYqi7gQcoeXOTlex68Hxy4R2ucb34dosNUQfqQvaCcE+ZsZXgclKy+k36zsDH8uDCvsLK9MCFW6FOVFW5zQaxTxlEf+PXUpMTr9dy0RJlAtfj09rwGJKfsO; AID=wmlspartner%3D0%3Areflectorid%3D0000000000000000000000%3Alastupd%3D1669363454690; SSP_AB_876878678=variant4; _sp_id.ad94=8d0a7c17-fbf8-467d-a9ba-4bb84c5d8b15.1669363456.1.1669363457.1669363456.57b5107c-5e00-4236-8521-e609c3a088c9; auth=MTAyOTYyMDE4sOs7grBquFdCsQ1KdvDrcOTmXMug5%2BkjMP9IqpTgOi9c0USZNbwUpRiFfzabmHV7cLjt3a6BLA1dQYOlV1UE3HG0Bu%2FjqjIgY24l%2FLCnfnKtCSg6tOwIrOJWz9pbPVRa767wuZloTfhm7Wk2KcjygglTqinKgSpV0hco0QKmh1CAigaMdpoVcnngFCXLA4W3CVzjPiulKykwUVaGCPu68lQQad6werBfNn3EPlJLUZMUMk70P8glgOEpLOprhDfMM%2FFHGZ2dCNmxWrdkwqEKrmM4g2ZwETkJBXsO4XI7ngKvEWLkn%2BsZkFImeMkZQ2wNxjrRXBn%2FYaysjpT8fbqa71ElzYH5XGp66ajg5XBJ9yHJPa8XnPZpaj74sesKFnw3G9%2FsQOyCpo2g3hWHrfWiO5E5WBBdZBCyKnCQAR7o6eg%3D; bstc=U3RhyBFrPyfYiLFZAeHlFw; mobileweb=0; xptc=assortmentStoreId%2B3081; xpth=x-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UkUiLCJhZGRyZXNzIjp7InBvc3RhbENvZGUiOiI5NTgyOSIsImFkZHJlc3NMaW5lMSI6Ijg5MTUgR2VyYmVyIFJvYWQiLCJjaXR5IjoiU2FjcmFtZW50byIsInN0YXRlIjoiQ0EiLCJjb3VudHJ5IjoiVVMiLCJwb3N0YWxDb2RlOSI6Ijk1ODI5LTAwMDAifSwiZ2VvUG9pbnQiOnsibGF0aXR1ZGUiOjM4LjQ4MjY3NywibG9uZ2l0dWRlIjotMTIxLjM2OTAyNn0sImlzR2xhc3NFbmFibGVkIjp0cnVlLCJzY2hlZHVsZWRFbmFibGVkIjp0cnVlLCJ1blNjaGVkdWxlZEVuYWJsZWQiOnRydWUsImFjY2Vzc1BvaW50cyI6W3siYWNjZXNzVHlwZSI6IkRFTElWRVJZX0FERFJFU1MifV0sImh1Yk5vZGVJZCI6IjMwODEiLCJpc0V4cHJlc3NEZWxpdmVyeU9ubHkiOmZhbHNlLCJzdXBwb3J0ZWRBY2Nlc3NUeXBlcyI6WyJERUxJVkVSWV9BRERSRVNTIl19LCJpbnN0b3JlIjpmYWxzZSwicmVmcmVzaEF0IjoxNjY5Mzg5MzgzOTExLCJ2YWxpZGF0ZUtleSI6InByb2Q6djI6ZTU5ODI0OWMtMDYxYS00YjRjLTllYjgtMTEwNmNlNWJhNzA1In0%3D; xptwj=rq:63f759739c4400a787b5:CB19mCe3uCAT//kTw0q4NaN2yociye6qfCdkZQwm555/weuvD/CZeiSZbIADHQfmAYlr6MYcODYak9WX8mxWZFs7jerYMpU3NgIxc00rtrPmJCqsPwpc; akavpau_p2=1669368769~id=927b623f61ed79191dd851e6c9c60917; xptwg=3619126938:62888C5C039570:FD81F9:E0940204:9D199AD2:A00E5D45:; com.wm.reflector="reflectorid:0000000000000000000000@lastupd:1669368384000@firstcreate:1669363411941"; TS012768cf=012aaf4750d104102433855e2bef7a77375f05236ec6c24c1530ca698da7850876cef5f4c04d2f67769e33d414d1917b6ef1a04c0f; TS01a90220=012aaf4750d104102433855e2bef7a77375f05236ec6c24c1530ca698da7850876cef5f4c04d2f67769e33d414d1917b6ef1a04c0f; TS2a5e0c5c027=0824e48b03ab20008d6e213641d4ba7fcb4bd26ca889884f6f716176d668e25c384e95a9e1e3ee620840dd0a3f11300011246b830cc2a27b1cd1348bba6adf0391c957300b85f7f8e64912818e809c4978d5a302cd145ca3ae9f903960bf5db2; bm_sv=3FE8982CCC490CF78C9A74355098563E~YAAQT/h33+dUc32EAQAAogwcrhFLBAYogf1/yZbrG2SYrcExmlljP9W5RJ++2sUZllrkhj446qrA+P1UJrHqP0uJuBOBJKhof7q+ejcJUrqgj0dibKmikpy7WzOt+UzE6MLANSa6olZsgw250VvP3GVnNl5lgnGUCfpwITK22QYB0nqhp0t0tWoG+OD695hQskNA/xapDPO68qW+g8cE+tCec1xxozMDT2eNFccdNfizykKWI++4gvdfr8ni4jI64Xo=~1',
'referer': 'https://www.google.com.hk/',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36'
}
self.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',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'zh-CN,zh;q=0.9',
'cookie': '_pxhd=d72621e2b07c28a1f2429308c9da062a968286848d7a67d48b826e44e9f57c16:6ef3bd8c-6be6-11ed-b9df-54655163516d; ACID=e598249c-061a-4b4c-9eb8-1106ce5ba705; hasACID=true; assortmentStoreId=3081; hasLocData=1; TB_Latency_Tracker_100=1; TB_Navigation_Preload_01=1; TB_SFOU-100=; vtc=Y--TgPPEE7yosKPSHqcBes; adblocked=false; _pxvid=6ef3bd8c-6be6-11ed-b9df-54655163516d; TBV=7; ak_bmsc=3F7F036150778BD906468CC9836379D7~000000000000000000000000000000~YAAQBy83FzZYmpmEAQAAbzrQrREG5O1z+AfnAjy9/8NaZqmc2sN3oWIvWywKiAF335MOHeSur/YvnAVX3IzdlPtYQxP9E/BtdDaqn8yUeTWJcmzKYJRhw+OG7G3hPWOl0GZnLGEhfRcgVUZH9aNivpx/odY5kvN8yuCWUkBmBbRohk6htm5dr2xHY0vYS+7INUTePlosFTYlqxHnZTQ8IaIn6gQ3ELJ6JAvCd2uXSJ++tNIQv80l52lAgI8FW/XMgeWvMMSlw7Jh+DuVr8WxTVw7cD5eoizif0WVjHfCnDrkEYQEwpT9xvR0V0KcXqfYgj0JVk86oEvpbz/yXBk07SHxcEclLkQ2GZCV5BH4/cycC6sQt8KtqYPWkN7w6dOtxzE8fAYqi7gQcoeXOTlex68Hxy4R2ucb34dosNUQfqQvaCcE+ZsZXgclKy+k36zsDH8uDCvsLK9MCFW6FOVFW5zQaxTxlEf+PXUpMTr9dy0RJlAtfj09rwGJKfsO; AID=wmlspartner%3D0%3Areflectorid%3D0000000000000000000000%3Alastupd%3D1669363454690; SSP_AB_876878678=variant4; _sp_id.ad94=8d0a7c17-fbf8-467d-a9ba-4bb84c5d8b15.1669363456.1.1669363457.1669363456.57b5107c-5e00-4236-8521-e609c3a088c9; auth=MTAyOTYyMDE4sOs7grBquFdCsQ1KdvDrcOTmXMug5%2BkjMP9IqpTgOi9c0USZNbwUpRiFfzabmHV7cLjt3a6BLA1dQYOlV1UE3HG0Bu%2FjqjIgY24l%2FLCnfnKtCSg6tOwIrOJWz9pbPVRa767wuZloTfhm7Wk2KcjygglTqinKgSpV0hco0QKmh1CAigaMdpoVcnngFCXLA4W3CVzjPiulKykwUVaGCPu68lQQad6werBfNn3EPlJLUZMUMk70P8glgOEpLOprhDfMM%2FFHGZ2dCNmxWrdkwqEKrmM4g2ZwETkJBXsO4XI7ngKvEWLkn%2BsZkFImeMkZQ2wNxjrRXBn%2FYaysjpT8fbqa71ElzYH5XGp66ajg5XBJ9yHJPa8XnPZpaj74sesKFnw3G9%2FsQOyCpo2g3hWHrfWiO5E5WBBdZBCyKnCQAR7o6eg%3D; bstc=U3RhyBFrPyfYiLFZAeHlFw; mobileweb=0; xptc=assortmentStoreId%2B3081; xpth=x-o-mverified%2Bfalse; xpa=; xpm=3%2B1669367780%2BY--TgPPEE7yosKPSHqcBes~%2B0; _astc=0c9c838905902e12f12b6ed908078e67; pxcts=d4d3d132-6ca1-11ed-acc7-56564173716f; locGuestData=eyJpbnRlbnQiOiJTSElQUElORyIsImlzRXhwbGljaXQiOmZhbHNlLCJzdG9yZUludGVudCI6IlBJQ0tVUCIsIm1lcmdlRmxhZyI6ZmFsc2UsImlzRGVmYXVsdGVkIjp0cnVlLCJzdG9yZVNlbGVjdGlvblR5cGUiOiJERUZBVUxURUQiLCJwaWNrdXAiOnsibm9kZUlkIjoiMzA4MSIsInRpbWVzdGFtcCI6MTY2OTM2MzQxMTk3Nn0sInNoaXBwaW5nQWRkcmVzcyI6eyJpZCI6bnVsbCwidGltZXN0YW1wIjoxNjY5MzYzNDExOTc2LCJjcmVhdGVUaW1lc3RhbXAiOm51bGwsInR5cGUiOiJwYXJ0aWFsLWxvY2F0aW9uIiwiZ2lmdEFkZHJlc3MiOmZhbHNlLCJwb3N0YWxDb2RlIjoiOTU4MjkiLCJjaXR5IjoiU2FjcmFtZW50byIsInN0YXRlIjoiQ0EiLCJkZWxpdmVyeVN0b3JlTGlzdCI6W3sibm9kZUlkIjoiMzA4MSIsInR5cGUiOiJERUxJVkVSWSJ9XX0sInBvc3RhbENvZGUiOnsidGltZXN0YW1wIjoxNjY5MzYzNDExOTc2LCJiYXNlIjoiOTU4MjkifSwibXAiOltdLCJ2YWxpZGF0ZUtleSI6InByb2Q6djI6ZTU5ODI0OWMtMDYxYS00YjRjLTllYjgtMTEwNmNlNWJhNzA1In0%3D; locDataV3=eyJpc0RlZmF1bHRlZCI6dHJ1ZSwiaXNFeHBsaWNpdCI6ZmFsc2UsImludGVudCI6IlNISVBQSU5HIiwicGlja3VwIjpbeyJidUlkIjoiMCIsIm5vZGVJZCI6IjMwODEiLCJkaXNwbGF5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XlOYW1lIjoiU2FjcmFtZW50byBTdXBlcmNlbnRlciIsIm5vZGVUeXBlIjoiU1RPUkUiLCJhZGRyZXNzIjp7InBvc3RhbENvZGUiOiI5NTgyOSIsImFkZHJlc3NMaW5lMSI6Ijg5MTUgR2VyYmVyIFJvYWQiLCJjaXR5IjoiU2FjcmFtZW50byIsInN0YXRlIjoiQ0EiLCJjb3VudHJ5IjoiVVMiLCJwb3N0YWxDb2RlOSI6Ijk1ODI5LTAwMDAifSwiZ2VvUG9pbnQiOnsibGF0aXR1ZGUiOjM4LjQ4MjY3NywibG9uZ2l0dWRlIjotMTIxLjM2OTAyNn0sImlzR2xhc3NFbmFibGVkIjp0cnVlLCJzY2hlZHVsZWRFbmFibGVkIjp0cnVlLCJ1blNjaGVkdWxlZEVuYWJsZWQiOnRydWUsImFjY2Vzc1BvaW50cyI6W3siYWNjZXNzVHlwZSI6IkRFTElWRVJZX0FERFJFU1MifV0sImh1Yk5vZGVJZCI6IjMwODEiLCJpc0V4cHJlc3NEZWxpdmVyeU9ubHkiOmZhbHNlLCJzdXBwb3J0ZWRBY2Nlc3NUeXBlcyI6WyJERUxJVkVSWV9BRERSRVNTIl19LCJpbnN0b3JlIjpmYWxzZSwicmVmcmVzaEF0IjoxNjY5Mzg5MzgzOTExLCJ2YWxpZGF0ZUtleSI6InByb2Q6djI6ZTU5ODI0OWMtMDYxYS00YjRjLTllYjgtMTEwNmNlNWJhNzA1In0%3D; xptwj=rq:c3880f2f78646e37f15b:SHuDmpQKQDf6csw7ZiWP53MJK3tBbkXZ/7oAaAd45fPPso9l1/PHyGfqXvo/m6W0VT3IGXukWHNAAOD+ZH+7GIfYBatBVrsFd58fwSw7utBwETo2ZX+4; com.wm.reflector="reflectorid:0000000000000000000000@lastupd:1669369023000@firstcreate:1669363411941"; xptwg=170097906:3D4F8494DBBC80:9DBD91:8B5A67E0:24F67035:7266A16F:; TS01a90220=012e979b62b59dfa8dde2b50031f4cb90cd6ca9cca7ee859dafee0eafaf04aa0d583d5181bda59b30696cb9a3f2fac96e529cbf661; _pxff_rf=1; _pxff_fp=1; _pxff_cfp=1; wmtboid=1669369151-3358699430-11433870400-35730845; TS012768cf=010f7d91788555bc8c5a9e060a0b08bb6786e373ba8423021972777816e78460edb16d3bd6958c2d5a431d44103edb9dc1c7cbcc30; TS2a5e0c5c027=081188e032ab20009f7fde9e0037bd7ee0ed4d8c8c15ad2e746b5d9e0b94a89d68fda92a2f52ac8a08b389192e1130005f935bf1d87d4bb08cb31684ea34747525b932e757ea5befdd3895e2e2d59c81fc1bc5329792f6ad5fd26546aea471f6; akavpau_p2=1669369752~id=996894bbc23fc304e8f303bd09ca2abf; bm_sv=3FE8982CCC490CF78C9A74355098563E~YAAQH/h330I8sHyEAQAAjcInrhFKT1yUVwfKXFaCN+Dcj7wZupJMhEBth5MtGtL3Qo8iCyxNm4UcQyK582kh1Vh+6EXXPSmMRwOa9lqwQ7ftVTJiFp/EgE2XqUh48EKn3Cr/+Je87I8ha9Gf2i7DE+CT81F1W30bf+iGYs9VqOJzyEL0FQ8QWH+NVwkOTBMmtPKSI8Y5MaXWs/snk4Xn0YfdDIEuZDFD3+g3k8t+9vVWWieF6+fAyoCU5EFfKIf0IgU=~1; _px3=7c1b21c45af942e9d29e767ffcf7b0ee94de15fe6cbc47bec656ac5df604a09f:+X6jANRJ8AsdR7vyrzG9ilGxiAXqIPGoa58D6T9RAvVF1OgvvqQYIeyeShodqMTv0yrgJNvF8Z9uS8GcXKulPg==:1000:6Ut6fH4tzMKY1TigxgUSvNs8ztTAZ6cx+07MXg8VeTzDOUjD/xzrfBZgrjDKaX4M+MJ8AZf98QlfzV4NQu7FD4NksP36zDJle9511HxyYadpz95QXp8N6d+j6mLxAFpX+YwXWW3gp6nIdT42q+Aj/pTF+A8rfhsjbS4RevyFDysxMj6Opmd0k0UqMKDDurSsnp4/7VzzG/AZBIcA7dEzNw==',
'referer': 'https://www.walmart.com/',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36'
}
self.comment_headers = {
'accept': '*/*',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'zh-CN,zh;q=0.9',
'cookie': 'ACID=f64a7418-c72b-4d0e-a716-baf860f93690; hasACID=true; assortmentStoreId=3081; hasLocData=1; vtc=SnEwPrqme-loupAVHXx7O4; _pxhd=8b718cd71eaa91acde426efbc41563a8059b897cb17e77a5af9cb825d6f0647f:024ea19b-657f-11ed-9eca-67534849584a; adblocked=false; TBV=7; _pxvid=024ea19b-657f-11ed-9eca-67534849584a; locGuestData=eyJpbnRlbnQiOiJTSElQUElORyIsImlzRXhwbGljaXQiOmZhbHNlLCJzdG9yZUludGVudCI6IlBJQ0tVUCIsIm1lcmdlRmxhZyI6ZmFsc2UsImlzRGVmYXVsdGVkIjp0cnVlLCJzdG9yZVNlbGVjdGlvblR5cGUiOiJERUZBVUxURUQiLCJwaWNrdXAiOnsibm9kZUlkIjoiMzA4MSIsInRpbWVzdGFtcCI6MTY2ODU4MzE2OTMxMn0sInNoaXBwaW5nQWRkcmVzcyI6eyJpZCI6bnVsbCwidGltZXN0YW1wIjoxNjY4NTgzMTY5MzEyLCJjcmVhdGVUaW1lc3RhbXAiOm51bGwsInR5cGUiOiJwYXJ0aWFsLWxvY2F0aW9uIiwiZ2lmdEFkZHJlc3MiOmZhbHNlLCJwb3N0YWxDb2RlIjoiOTU4MjkiLCJjaXR5IjoiU2FjcmFtZW50byIsInN0YXRlIjoiQ0EiLCJkZWxpdmVyeVN0b3JlTGlzdCI6W3sibm9kZUlkIjoiMzA4MSIsInR5cGUiOiJERUxJVkVSWSJ9XX0sInBvc3RhbENvZGUiOnsidGltZXN0YW1wIjoxNjY4NTgzMTY5MzEyLCJiYXNlIjoiOTU4MjkifSwibXAiOltdLCJ2YWxpZGF0ZUtleSI6InByb2Q6djI6ZjY0YTc0MTgtYzcyYi00ZDBlLWE3MTYtYmFmODYwZjkzNjkwIn0%3D; SSP_AB_876878678=variant3; TB_Latency_Tracker_100=1; TB_Navigation_Preload_01=1; TB_SFOU-100=; pxcts=544cc85d-6c06-11ed-b130-6e7563664a53; wmlh=373ee6e96c6493161f32715826da637bbf50b40042574f2c0ac3327bbdc63543; _astc=eacdc3070249307b550af97449a7abef; AID=wmlspartner%3D0%3Areflectorid%3D0000000000000000000000%3Alastupd%3D1669364631190; _sp_id.ad94=01f21020-c9d8-4b55-8064-18800d92de56.1669194297.7.1669366558.1669363915.50e4c6cf-70db-4b46-a5a9-3ac9fb2d21f6; akavpau_p2=1669368501~id=2073dda1e5e90c71d4e8656ac67ea44d; wmtboid=1669369339-1044854368-3556951040-11115472; bm_mi=38480D390BBFB9B5497006DFB4F2CBE2~YAAQBkVnaJBrMH+EAQAA5p8qrhFcyy+wNWpXq8ExujvwZKfZFfE7zuMKeZjcnb36qUarmAU4iOLpQ7SZ+/ePfeTubLefXzGAJoD56QNfz3NPrzER52fHWbPVMv2z8gAT0W9Iy5eiWIvMqp5fn2C0JtNLdiLwUfgtzWYZlqGug63vMWS08PF7y1QslsTQiilQnK8kkIKTbCz2xxx6duTrxqzuma1f+D0VnJuJXzmFpP0aH+PW0Eq99hVkTxNsivrsgiMLe4ZqZvWh2Tb+QcQBuUpEWSaxIpwAgBBhd9X7BkzfbzjjA2GBMAgAHJXcugBiccVCgU0=~1; auth=MTAyOTYyMDE4N25FAITILebh1cbiB%2BHQoo8UVVXDMqfTYGKZIQgxX2BFnbMAc2xKHXw%2BhQGaq2n%2FZkucZkV1mRxqwv3J0BRGtbxKQUViNqgzgUsY3eyNPQ0zpBe162dcfPJlYOzviXUm767wuZloTfhm7Wk2KcjyglM949MaUzwsNnQKx2EXSLmBBgUQ5lHzZ3JZJprnwmJu79zoqhMUVCTE99In6JWJmQo2DXCph763Xgs3FJr0n5EUMk70P8glgOEpLOprhDfMM%2FFHGZ2dCNmxWrdkwqEKrmnqZOz0zmedjKWBihaM6VZDAwdyqsegRh0E0JvLBqrrL9%2Fm5SMdNd4HjXTcHNnGIMb3NOtNaiTV4EnG%2FDemzG3JPa8XnPZpaj74sesKFnw3NYzCVM3Kh%2F2sxIBe1TVODJE5WBBdZBCyKnCQAR7o6eg%3D; bstc=QmK_Z1-UfTd4tRYmQFblwo; mobileweb=0; xptc=assortmentStoreId%2B3081; xpth=x-o-mverified%2Bfalse; xpa=; xpm=3%2B1669369367%2BSnEwPrqme-loupAVHXx7O4~%2B0; xptwj=rq:d4e885bc442752205186:yFxcWoq2nRPfh2o1zMe6ZS7zElzjTqhPKVvEnQzB7LEax51YeBsySaIEG95TjfoLUOJhEfyOA1JRfE5fBbT7bD+bjZL33n2ZBrEUwCFRt4nSISj45+zyrs3hJrUBGybr1uybKdIFEDcmeD7smSzBH3XRKhGq9p6QiA==; ak_bmsc=573F46668A5FA99E0966F200EE035CB8~000000000000000000000000000000~YAAQBkVnaOprMH+EAQAA5A4rrhG837Zk/f1nVL+d4cO9c5nR5zE6LceLwOKOpYNhuFw8k9bsX5/QlT+b2Qhffps/+vnzFuESdrQNHmgFTPFv11i38d3doX3r/6FQ2PaG+LjXU+iKK5cbmg3Kb7t8H+sgJvrBOqDxqdCahx8d+8jvB2h8OG7bI8VtjT39ZNiyYYrUodln5I+W2SqpGWeQRsBqNQIMvZO3hJ4tcLViIkWiD0NFThHCw4gkJgh2JqJ2ItRSHV6BRGrKiyRQutpLl0aGVPSvbfbEoa2v4ugcsdiuXpmHsY3IFunhvEWR8Jud6lfJPJDAdge6TIWH0bkobSAQQ5j3MDuQq2nUzMON/2h2QxbFDB070sa+yG0k5pprzHW/HvNp4ukvkcu+x34rKnK7ZbM4FlbPsitNLqzd+zdznu/VbA==; com.wm.reflector="reflectorid:0000000000000000000000@lastupd:1669369369000@firstcreate:1668583169275"; locDataV3=eyJpc0RlZmF1bHRlZCI6dHJ1ZSwiaXNFeHBsaWNpdCI6ZmFsc2UsImludGVudCI6IlNISVBQSU5HIiwicGlja3VwIjpbeyJidUlkIjoiMCIsIm5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ibm9kZUlkIjoiMzA4MSIsImRpc3BsYXlOYW1lIjoiU2FjcmFtZW50byBTdXBlcmNlbnRlciIsIm5vZGVUeXBlIjoiU1RPUkUiLCJhZGRyZXNzIjp7InBvc3RhbENvZGUiOiI5NTgyOSIsImFkZHJlc3NMaW5lMSI6Ijg5MTUgR2VyYmVyIFJvYWQiLCJjaXR5IjoiU2FjcmFtZW50byIsInN0YXRlIjoiQ0EiLCJjb3VudHJ5IjoiVVMiLCJwb3N0YWxDb2RlOSI6Ijk1ODI5LTAwMDAifSwiZ2VvUG9pbnQiOnsibGF0aXR1ZGUiOjM4LjQ4MjY3NywibG9uZ2l0dWRlIjotMTIxLjM2OTAyNn0sImlzR2xhc3NFbmFibGVkIjp0cnVlLCJzY2hlZHVsZWRFbmFibGVkIjp0cnVlLCJ1blNjaGVkdWxlZEVuYWJsZWQiOnRydWUsImFjY2Vzc1BvaW50cyI6W3siYWNjZXNzVHlwZSI6IkRFTElWRVJZX0FERFJFU1MifV0sImh1Yk5vZGVJZCI6IjMwODEiLCJpc0V4cHJlc3NEZWxpdmVyeU9ubHkiOmZhbHNlLCJzdXBwb3J0ZWRBY2Nlc3NUeXBlcyI6WyJERUxJVkVSWV9BRERSRVNTIl19LCJpbnN0b3JlIjpmYWxzZSwicmVmcmVzaEF0IjoxNjY5MzkwOTY5MjI1LCJ2YWxpZGF0ZUtleSI6InByb2Q6djI6ZjY0YTc0MTgtYzcyYi00ZDBlLWE3MTYtYmFmODYwZjkzNjkwIn0%3D; xptwg=2960516040:11A09D5B16E7070:2D5A17A:F8BD93B5:2B47C8F8:963868FE:; TS012768cf=014e9abc5bf04d714c38c4b13a785cea29fcdabecf4c4afe7106bfb96394360979c66d99d4ff72ffb01109393050b8a0f579783f08; TS01a90220=014e9abc5bf04d714c38c4b13a785cea29fcdabecf4c4afe7106bfb96394360979c66d99d4ff72ffb01109393050b8a0f579783f08; TS2a5e0c5c027=08754faef6ab20008645b15dff05ab2a6ba533fb010a362508e63ce7df1f503107d2f02b8c4721e508bee163b9113000ef19a69a82e0a89619635a774e2d83321d75f0feb32908d3af29341d987b33bffe40c1b95d152e5651b90e3f9fdab44a; bm_sv=22163221D0251E43E4D107C49DBBDDFE~YAAQBkVnaPJrMH+EAQAA4RIrrhFodszoMaFWaCXqP3X5Gn1PbdbKnKuiG0F5gfxAsPFhxsgFIZBir9BCrqnieGGHWk9iOUCbxaT17l67x/Z0tQALe5pkdbnSGL3CYMDIZROp7TQogoCb9vg4EKYX+7NkOr8VcBK1WoVoWaD8hnYDjvJdfuqNyGi76TxZ4fvI1tnv4fL4FXT9oTiDmVrgF0pvxpmQUAYIODbvCxePCsEnA5e159pGuFePsG2Gj/Hg3CQ=~1; _px3=dbadc57799ace4f85695978a5e52c08fc25e24bae1a384b8e5f9dc00aac3fe53:omZs/An1pufl43Cc7yzCwDIGfG9pwo8y1RUBsuYp/16KrO4hDPBE6uihE0SmkjExhelhVpbiUyMeGKuFfrBnVg==:1000:kW1ejPHb3SFPo2wxli3l+PMRppXVJFORt356mIOSObUD0MAyrNvrdO1//jNFHG4WNlVmUzALWzhqeiA2ouAjNctd9UGqNOZKGanbst/7OUP9J/aPpVF/AWhhctap1DQR4fMw47znatU4lAVU6OsrHAf47SX7Pc9ZIm+rhWSPa+Jm8PAdOuIKIKsMjb/ZXzsdlCWPSemfnXZJHxMcq9oLIA==',
'referer': '',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36'
}
self.sheet = open_gsheet('US COMMENTS', 'walmart')
self.rq = Request()

def request_retry(self, url, headers={}):
if not headers:
headers = self.headers
i = 0
while i < 20:
try:
# r = requests.get(url, headers=headers, timeout=20)
r = self.rq.requests_get(url, headers=headers)
if "Robot or human" in r.text:
print("Robot or human")
i += 1
sleep2(10)
print(f'try {i} times')
continue
if r.status_code in [404]:
i += 1
sleep2(10)
print(f'try {i} times, 404')
continue
break
except Exception as e: # 网站原因
i += 1
sleep2(10)
print(f'try {i} times, {e.args}')
else:
raise
return r

def treat_comment_page(self, id, page):
"""评论时间	评价星级	评价文字内容	图片"""
url = f'https://www.walmart.com/reviews/product/{id}?page={page}'
# print(url)
self.comment_headers['referer'] = url
r = self.request_retry(url, headers=self.comment_headers)
# r = self.rq.requests_get(url, headers=self.headers)
# print(r.status_code, r.text[:1000])
soup = BeautifulSoup(r.text, 'lxml')
comments_tag = soup.select('.dib.w-100.mb3')
comments = []
for comment_tag in comments_tag:
comment_time = comment_tag.select('.justify-content > div:nth-child(2) div')[0].text.strip().strip()
comment_content = comment_tag.select('.lh-copy')[0].text.replace('\n', '').strip()
comment_star = len(comment_tag.select('.justify-content .ld-StarFill'))
# print(comment_time, comment_star, comment_content)
comment_data = [' ', ' ', ' ', ' ', ' ', comment_time, comment_star, comment_content]
comments.append(comment_data)
print('comments', len(comments))
if len(comments) == 0:
return False
gsheet_append_rows(self.sheet, comments)
next_page = soup.select('[aria-label="pagination"] [data-testid="NextPage"]')
if len(next_page) == 1:
return True
else:
return False

def parse_exception(self, obj):
res = obj.result()
if res:
print(res)

def get_comment(self, id):
page = 1
while True:
logger.info(f'id:{id}, page:{page}')
res = self.treat_comment_page(id, page)
time.sleep(random.randint(1, 60))
if res:
page += 1
else:
break

def detail(self, url):
response = self.request_retry(url)
# print(response.status_code, response.text)
soup = BeautifulSoup(response.text, 'lxml')
try:
title = soup.select('[data-testid="sticky-buy-box"] h1')[0].text.strip()
except:
raise Exception(f'{response.status_code}, {response.text}')
try:
price = soup.select('.pt3 [itemprop="price"]')[0].text.replace('Now', '').strip()
except:
raise Exception(f'url:{url} {response.text}')
# except IndexError:
# if 'Currently unavailable' in response.text:
# price = 'Currently unavailable'
# else:
# price = 'error'
img_url = soup.select('[loading="eager"]')[0].attrs['src']
img_url = f'=IMAGE("{img_url}")'
category = soup.select('[aria-label="breadcrumb"] [itemprop="name"]')
category = '/'.join([i.text for i in category])
sku_data = [title, price, img_url, category, url, ' ',' ',' ']
print('sku_data', sku_data)
gsheet_append_row(self.sheet, sku_data)
sku_id = url.split('/')[-1].split('?')[0]
self.get_comment(sku_id)

def treat_one_page(self, url, page):
url = url.split('page=')[0] + 'page=' + str(page)
response = self.request_retry(url)
p = re.compile('"items":(\[.*?"buyBoxSuppression":false}\])')
d = re.search(p, response.text).group(1)
# print(d)
d = re.sub('"description":".*?",', '"description":"",', d)
d = re.sub('"name":".*?",', '"name":"",', d)
# print(d)
s = json.loads(d)
item_urls = []
for index, i in enumerate(s):
try:
item_urls.append('https://www.walmart.com' + i['canonicalUrl'])
except:
pass
print('item_urls', len(item_urls), item_urls)
for idx, item_url in enumerate(item_urls):
if idx < 36:
continue
logger.info(f'{idx}/{len(item_urls)} {item_url}')
self.detail(item_url)
time.sleep(random.randint(10, 60))

def main(self):
urls = ['https://www.walmart.com/browse/clothing/women/5438_133162?povid=FashionGlobalNav_Women_Clothing&sort=best_seller&page=1']
for url in urls:
# 就取前3页
for page in range(1, 4):
logger.info(f'url: {url}, page:{page}')
self.treat_one_page(url, page)
break


if __name__ == '__main__':
a = Walmart()
a.main()
# a.detail('https://www.walmart.com/ip/Time-and-Tru-Women-s-High-Rise-Knit-Leggings-3-Pack/271198063?athbdg=L1800')

  


欢迎关注:爬虫王者

标签:comment,headers,url,text,self,获取,walmart,数据,page
From: https://www.cnblogs.com/crawler-king/p/16988679.html

相关文章

  • C/C++数据结构课程设计[长春理工大学计算机科学技术学院2022秋季学期]
    C/C++数据结构课程设计[长春理工大学计算机科学技术学院2022秋季学期]长春理工大学计算机科学技术学院2022秋季学期数据结构课程设计一、目的:巩固数据结构与算法课内......
  • 基于Mybatis-Plus实现Geometry字段在PostGis空间数据库中的使用
    背景在OGC标准中,通常空间字段是由Geometry类型来表示。而一般编程语言中是没有这种数据类型的。以java为例,怎么操作这些数据,满足业务需求呢?跟着本文一起来学习吧。今天介绍......
  • 数据库scn以及对应的时间查询
    文档课题:数据库scn以及对应的时间查询.--查某时间段scn号selectscn,to_char(time_dp+interval'8'hour,'yyyy-mm-ddhh24:mi:ss')fromsys.smon_scn_timewhereto_......
  • Bash Shell获取建行官网最新公告列表(Bash Shell抓取网页小案例)
    BashShell获取建行官网公告列表没啥实质作用,纯粹是因为懒得打开浏览器的情况下想确认建行有无发表新公告,练手一下...,查看具体的公告内容,还得浏览器打开详情页网址,所以,然......
  • VUE数据双向绑定
    5.Vue数据双向绑定5.1.什么是双向数据绑定Vue.js是一个MVVM框架,即数据双向绑定,即当数据发生变化的时候,视图也就发生变化,当视图发生变化的时候,数据也会跟着同步变......
  • magento获取当前路径
    有时候我们需要获取当前路径来做一些事情,不废话了,直接上代码​​01​​​​<?php​​​​02​​​​$urlRequest​​​​​=Mage::app()->getFrontController......
  • 数据库设计流程
    对于上图的解读,菱形中是对对象的行为,矩形是大的对象类,有两边的矩形是细分类每两个图形中间都要连线,线上划一圈表示从属关系,表示做,l表示被做,和l一般在菱形两边,......
  • 数据结构之哈希表
    wikipedia上的解释​​http://zh.wikipedia.org/wiki/%E5%93%88%E5%B8%8C%E8%A1%A8​​下图示意了哈希表(HashTable)这种数据结构。哈希表如上图所示,首先分配一个指针......
  • 数据结构之 插入排序
    插入排序:包括:​​直接插入排序​​,二分插入排序(又称折半插入排序),链表插入排序,​​希尔排序​​(又称缩小增量排序)。插入排序算法思路假定这个​​数组​​的序是排好的,......
  • pytest + yaml 框架 -16.提供一个常用的内置函数和方法生成随机测试数据
    前言在测试的过程中经常会用到一些随机值,比如生成随机手机号,随机身份证,姓名等数据。内置方法目前暂时提供了3个内置函数,和1个内置对象current_time(f:str='%Y-%m-%......