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

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

"""====================================================================================================================
@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=eyJpc0RlZmF1bHRlZCI6dHJ1ZSwiaXNFeHBsaWNpdCI6ZmFsc2UsImludGVudCI6IlNISVBQSU5HIiwicGlja3VwIjpbeyJidUlkIjoiMCIsIm5vZGVJZCI6IjMwODEiLCJkaXNwbGF5TmFtZSI6IlNhY3JhbWVudG8gU3VwZXJjZW50ZXIiLCJub2RlVHlwZSI6IlNUT1JFIiwiYWRkcmVzcyI6eyJwb3N0YWxDb2RlIjoiOTU4MjkiLCJh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HJlc3NMaW5lMSI6Ijg5MTUgR2VyYmVyIFJvYWQiLCJjaXR5IjoiU2FjcmFtZW50byIsInN0YXRlIjoiQ0EiLCJjb3VudHJ5IjoiVVMiLCJwb3N0YWxDb2RlOSI6Ijk1ODI5LTAwMDAifSwiZ2VvUG9pbnQiOnsibGF0aXR1ZGUiOjM4LjQ4MjY3NywibG9uZ2l0dWRlIjotMTIxLjM2OTAyNn0sImlzR2xhc3NFbmFibGVkIjp0cnVlLCJzY2hlZHVsZWRFbmFibGVkIjp0cnVlLCJ1blNjaGVkdWxlZEVuYWJsZWQiOnRydWUsImFjY2Vzc1BvaW50cyI6W3siYWNjZXNzVHlwZSI6IkRFTElWRVJZX0FERFJFU1MifV0sImh1Yk5vZGVJZCI6IjMwODEiLCJpc0V4cHJlc3NEZWxpdmVyeU9ubHkiOmZhbHNlLCJzdXBwb3J0ZWRBY2Nlc3NUeXBlcyI6WyJERUxJVkVSWV9BRERSRVNTIl19LCJpbnN0b3JlIjpmYWxzZSwicmVmcmVzaEF0IjoxNjY5Mzg5MzgzOTExLCJ2YWxpZGF0ZUtleSI6InByb2Q6djI6ZTU5ODI0OWMtMDYxYS00YjRjLTllYjgtMTEwNmNlNWJhNzA1In0%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-o-mverified%2Bfalse; xpa=; xpm=3%2B1669367780%2BY--TgPPEE7yosKPSHqcBes~%2B0; _astc=0c9c838905902e12f12b6ed908078e67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yIFJvYWQiLCJjaXR5IjoiU2FjcmFtZW50byIsInN0YXRlIjoiQ0EiLCJjb3VudHJ5IjoiVVMiLCJwb3N0YWxDb2RlOSI6Ijk1ODI5LTAwMDAifSwiZ2VvUG9pbnQiOnsibGF0aXR1ZGUiOjM4LjQ4MjY3NywibG9uZ2l0dWRlIjotMTIxLjM2OTAyNn0sImlzR2xhc3NFbmFibGVkIjp0cnVlLCJzY2hlZHVsZWRFbmFibGVkIjp0cnVlLCJ1blNjaGVkdWxlZEVuYWJsZWQiOnRydWUsImFjY2Vzc1BvaW50cyI6W3siYWNjZXNzVHlwZSI6IkRFTElWRVJZX0FERFJFU1MifV0sImh1Yk5vZGVJZCI6IjMwODEiLCJpc0V4cHJlc3NEZWxpdmVyeU9ubHkiOmZhbHNlLCJzdXBwb3J0ZWRBY2Nlc3NUeXBlcyI6WyJERUxJVkVSWV9BRERSRVNTIl19LCJpbnN0b3JlIjpmYWxzZSwicmVmcmVzaEF0IjoxNjY5Mzg5MzgzOTExLCJ2YWxpZGF0ZUtleSI6InByb2Q6djI6ZTU5ODI0OWMtMDYxYS00YjRjLTllYjgtMTEwNmNlNWJhNzA1In0%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;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XNzIjp7InBvc3RhbENvZGUiOiI5NTgyOSIsImFkZHJlc3NMaW5lMSI6Ijg5MTUgR2VyYmVyIFJvYWQiLCJjaXR5IjoiU2FjcmFtZW50byIsInN0YXRlIjoiQ0EiLCJjb3VudHJ5IjoiVVMiLCJwb3N0YWxDb2RlOSI6Ijk1ODI5LTAwMDAifSwiZ2VvUG9pbnQiOnsibGF0aXR1ZGUiOjM4LjQ4MjY3NywibG9uZ2l0dWRlIjotMTIxLjM2OTAyNn0sImlzR2xhc3NFbmFibGVkIjp0cnVlLCJzY2hlZHVsZWRFbmFibGVkIjp0cnVlLCJ1blNjaGVkdWxlZEVuYWJsZWQiOnRydWUsImFjY2Vzc1BvaW50cyI6W3siYWNjZXNzVHlwZSI6IkRFTElWRVJZX0FERFJFU1MifV0sImh1Yk5vZGVJZCI6IjMwODEiLCJpc0V4cHJlc3NEZWxpdmVyeU9ubHkiOmZhbHNlLCJzdXBwb3J0ZWRBY2Nlc3NUeXBlcyI6WyJERUxJVkVSWV9BRERSRVNTIl19LCJpbnN0b3JlIjpmYWxzZSwicmVmcmVzaEF0IjoxNjY5Mzg5MzgzOTExLCJ2YWxpZGF0ZUtleSI6InByb2Q6djI6ZTU5ODI0OWMtMDYxYS00YjRjLTllYjgtMTEwNmNlNWJhNzA1In0%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=eyJpc0RlZmF1bHRlZCI6dHJ1ZSwiaXNFeHBsaWNpdCI6ZmFsc2UsImludGVudCI6IlNISVBQSU5HIiwicGlja3VwIjpbeyJidUlkIjoiMCIsIm5vZGVJZCI6IjMwODEiLCJkaXNwbGF5TmFtZSI6IlNhY3JhbWVudG8gU3VwZXJjZW50ZX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ciIsIm5vZGVUeXBlIjoiU1RPUkUiLCJhZGRyZXNzIjp7InBvc3RhbENvZGUiOiI5NTgyOSIsImFkZHJlc3NMaW5lMSI6Ijg5MTUgR2VyYmVyIFJvYWQiLCJjaXR5IjoiU2FjcmFtZW50byIsInN0YXRlIjoiQ0EiLCJjb3VudHJ5IjoiVVMiLCJwb3N0YWxDb2RlOSI6Ijk1ODI5LTAwMDAifSwiZ2VvUG9pbnQiOnsibGF0aXR1ZGUiOjM4LjQ4MjY3NywibG9uZ2l0dWRlIjotMTIxLjM2OTAyNn0sImlzR2xhc3NFbmFibGVkIjp0cnVlLCJzY2hlZHVsZWRFbmFibGVkIjp0cnVlLCJ1blNjaGVkdWxlZEVuYWJsZWQiOnRydWUsImFjY2Vzc1BvaW50cyI6W3siYWNjZXNzVHlwZSI6IkRFTElWRVJZX0FERFJFU1MifV0sImh1Yk5vZGVJZCI6IjMwODEiLCJpc0V4cHJlc3NEZWxpdmVyeU9ubHkiOmZhbHNlLCJzdXBwb3J0ZWRBY2Nlc3NUeXBlcyI6WyJERUxJVkVSWV9BRERSRVNTIl19LCJpbnN0b3JlIjpmYWxzZSwicmVmcmVzaEF0IjoxNjY5MzkwOTY5MjI1LCJ2YWxpZGF0ZUtleSI6InByb2Q6djI6ZjY0YTc0MTgtYzcyYi00ZDBlLWE3MTYtYmFmODYwZjkzNjkwIn0%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')

欢迎关注:爬虫王者

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 214,377评论 6 496
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,390评论 3 389
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 159,967评论 0 349
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,344评论 1 288
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,441评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,492评论 1 292
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,497评论 3 412
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,274评论 0 269
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,732评论 1 307
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,008评论 2 328
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,184评论 1 342
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,837评论 4 337
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,520评论 3 322
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,156评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,407评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,056评论 2 365
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,074评论 2 352

推荐阅读更多精彩内容