From e5e2e117ea8eb805ce804dd79cb2048299fa4aef Mon Sep 17 00:00:00 2001 From: CustomerAcquisition <2797027626@qq.com> Date: Wed, 5 Jun 2024 01:13:11 +0800 Subject: [PATCH] 0605 --- py1/20240604dy.py | 44 ++++ py1/抖音评论.csv | 28 ++- py1/获客/__pycache__/douyin.cpython-311.pyc | Bin 0 -> 2627 bytes .../__pycache__/douyinconnect.cpython-311.pyc | Bin 2072 -> 2933 bytes .../__pycache__/quchong.cpython-311.pyc | Bin 542 -> 644 bytes .../__pycache__/zidongcaozuo.cpython-311.pyc | Bin 0 -> 3759 bytes py1/获客/douyinconnect.py | 16 +- py1/获客/jiemian.py | 30 +++ py1/获客/quchong.py | 4 +- py1/获客/zidongcaozuo.py | 191 ++++++++++-------- py1/获客/抖音.py | 61 +++--- 11 files changed, 251 insertions(+), 123 deletions(-) create mode 100644 py1/20240604dy.py create mode 100644 py1/获客/__pycache__/douyin.cpython-311.pyc create mode 100644 py1/获客/__pycache__/zidongcaozuo.cpython-311.pyc create mode 100644 py1/获客/jiemian.py diff --git a/py1/20240604dy.py b/py1/20240604dy.py new file mode 100644 index 0000000..511cda6 --- /dev/null +++ b/py1/20240604dy.py @@ -0,0 +1,44 @@ +import time +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.common.keys import Keys + +options = webdriver.EdgeOptions() + +options.add_argument("--start-maximized") # 最大化窗口 +options.add_argument("--disable-notifications") # 禁用通知 + +options.add_argument("user-data-dir=C:/Users/JJM/AppData/Local/Microsoft/Edge/User Data/Default") # 使用本地用户数据目录 + +options.add_experimental_option("detach", True) + +driver = webdriver.Edge(options=options) + + +driver.get("https://www.douyin.com/user/MS4wLjABAAAAL8jDZ46yxoNUO9cr312r6PcKPYNipzcHqIKFbfpQIxM") + +driver.implicitly_wait(15) # 隐式等待,最长等20秒 +time.sleep(6) + +buttons = driver.find_element(By.XPATH,'//div[@class="hLIm2dFu"]/button[@class="semi-button semi-button-secondary RH8TCnaE z0c5Gipx I4tJiW0Q"]') + +buttons.click() +driver.implicitly_wait(15) # 隐式等待,最长等20秒 +time.sleep(5) + +# j6SRMBFG +# divi = driver.find_element(By.XPATH,'//div[@class="IaCaREVo"]') +# divi = driver.find_element(By.XPATH,'//div[@class="j6SRMBFG"]') +# divi.click() +# 定位输入框,正常输入框是input,但是这个用的是div,然后div有一个contenteditable属性设置成true就变成了输入框了 +# 所以定位带contenteditable 属性的div相当于定位了输入框input +divn = driver.find_element(By.XPATH,'//div[@class="notranslate public-DraftEditor-content"]') + +time.sleep(3) +divn.send_keys('6666666666',Keys.ENTER) +time.sleep(5) +ent=driver.find_element(By.XPATH,'//div[@id="root"]') +ent.send_keys(Keys.ENTER) +time.sleep(3) +spans = driver.find_element(By.XPATH,'//span[@class="sCp7KhBv EWT1TDgs e2e-send-msg-btn"]') +spans.click() \ No newline at end of file diff --git a/py1/抖音评论.csv b/py1/抖音评论.csv index 73e5ef0..1fd241c 100644 --- a/py1/抖音评论.csv +++ b/py1/抖音评论.csv @@ -11,13 +11,33 @@ 嘎兰花儿,1103292172,哈哈,太知道了,我不提醒,我家夫君两天都不会干,我提醒了,他就说我本来就会去干的,曾经大夏天让他自己吃的西瓜皮放茶几上两天! MAGO party气球派对布置,1162629054,这么好的解说不能下载[捂脸]我还想发给家庭群看看呢 白云无尽时,2251181178,老师能读一下李娟的作品《我的阿勒泰》吗,谢谢! -大志爸爸,68830320,"教育的本质不在于灌输,在于点燃火焰! -学习了" +大志爸爸,68830320,教育的本质不在于灌输,在于点燃火焰!学习了 Shameless,35598233242,哪怕你有99个白球,你摸到了黑球,那么你就只有黑球了。 㸚燚,2801279137,了不起的自驱力 疯癫小浪,29899141302,我会整理下茶几,顺便看下有什么需要一起整理的。 随便打的,58057786825,这个好,我要用这本书开发一套课程 季易安,36859095256,以为是不略呢 -孟娜丽莎,853410475,"让孩子自己安排时间,孩子不会安排的,最后玩的都忘记了。学习这个事情是主动的,我小时候学习,从不用说,老师一边布置我一边写,每次学校都把作业完成了。 -如果自己做好了,家长就不会说了。主要是孩子自身的原因,自己不主动" +孟娜丽莎,853410475,让孩子自己安排时间,孩子不会安排的,最后玩的都忘记了。学习这个事情是主动的,我小时候学习,从不用说,老师一边布置我一边写,每次学校都把作业完成了。如果自己做好了,家长就不会说了。主要是孩子自身的原因,自己不主动 多多做得到,1467070616,非常棒! +昵称,账号,评论 +昵称,账号,评论 +好听的名字,1396822405,第一个感觉老公是装的[九转大肠] +沧月,1048097576,这个是我的爱,其实在一起一辈子不吵架是不可能的,只是在吵架的时候或者过后能不能回想起他之前的好就是另外一回事儿,也会影响到后面还会不会在一起。[比心] +刘憨憨🍀,1340099500,纯爱版的悬溺 +meteora,1047016341,下一个给我推的就是这个 +「F。,1047851117,600块都要逃单?这群朋友物质和情义二者一个都没有 +23.8万等人,885855025,故意拍摄的啊 大家爱看。 +呆滞,58650318928,科幻片 +乘风的 海浪,51175596404,是不看得不想结婚的都想结婚了 +乱糟糟🐾,2946118630,第一个我建议这桌人全绝交就行了,一起喝酒喝完不送不说,别人都喝多睡着了,一桌没一个结账的[尬笑][尬笑][尬笑]什么朋友都是 +安冉安乐,3717028503,你这媳妇做饭不要给我看,因为我不会。也不要给我老公,我怕他多想。 +狂徒,45600071728,抖抖音看多了会得妄想症😳 +无!,59244860271,大哥都看蒙了 +海幸福,346083670,以前什么好的都想留给他顾不上自己最后…… +Licia👱🏼‍♀️,60476459398,我点了不感兴趣 我的老公不配 伤透心了 +2231613459,2231613459,无效的社交不如在家陪老婆。 +风吹过我的头发(搬砖版),908114924,刚看了骑水泥封心又要让我裂开是吧[捂脸] +QWEN,174856020,第二个表演的尴尬死了 +闻♥,24576166963,内个,我不是在做梦吧?[抱抱你][一起加油] +十四阿哥,2843786537,第一个那个男人以后肯定不会再跟那些所谓的朋友一起喝酒了! +🦻♪(´不🉑话🦔de阿La斯加🐬,136094221,我愿意嘿嘿嘿[呲牙] diff --git a/py1/获客/__pycache__/douyin.cpython-311.pyc b/py1/获客/__pycache__/douyin.cpython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w!w-D|GP?sfNC zwU-P|U!FZuV2|YLgA9VZeKs-#6FF=E!RYdM=wHJ{iTkS>ElWQGCWY1Q65!tfUet`Lr9BLUA P(Z$$@xXZtL literal 0 HcmV?d00001 diff --git a/py1/获客/__pycache__/douyinconnect.cpython-311.pyc b/py1/获客/__pycache__/douyinconnect.cpython-311.pyc index babcaf96366c2ec23eb0b7cdc7b5c879a1a391e0..5a85d845946322b0abf2719d376938cea7a0618c 100644 GIT binary patch delta 1642 zcmb6ZYfM{J_?&z0tL<$IrNbf>%AlE@ghvTWwrp+$HWsWHAAd%sr1o5(X_)8K)vKW7OZtE?u#UK05Ip6u- z_kNF@cdGVkT^~E0c0geL`U@jV%(BY|Bg@AE^#}t@N%T z1MoJ$5CaKlKm|Fd|3U@NP#9qvGnjpk)}X?eamz4{DirZ71NO#&3RmG0)F_q8F(ks# zjD{4aWdH!?Fpq85?Q6vS(@KbLpwWtZ-)fw_-9Et=irN?^B1ffZ!6qK(oDMOYr4;3QmD(bO}sB8~DE;##P>X z!w^$fxytrKU#-5+&`v7StvN~!c58wvvH$z`Mp2sgO~*YJjXi6bLrsEU z@kFAl87L24u9^oe7pVXl2>n;;C{0GLh7{v5L_}uOEI~_^Rol>!LD?J?J&JzN!}OWV z?6GIhN6z;?7nmK3CPv4i$-sqYo_aEXlj)gw;z~R*Dy0+CakA4*#O=5Br8{qae&_WY z+u!OtpRI3See3s?`HJhG->v-7K&;X}g39WOF0j4&#m?6soeF#cLSBQLOvlEOiBSVl zlW9FgU(WC&q7oa6N|GVW#xYUFqRH8G(qPM+K`ZeI(O^=NC|)s`n3PP3A*bvmA2MwC z#o<^oF%l=?Vu@+l?4Ci7#3fPonT z*=%ykoaw+p*y|t?y^*P7cb2}{zVV@cmZ=MdiHtMNS4dg2ph$bNgXSvIj#ma=9+->F zN3xNxMi~c0G}Ef5+3^hRWV}V*b=CEnEC0~BExxC~_vHDWqOait_lkSV7b^Hd3(niT zGw-%L4ZqFRCs z_ry$U@}$&8CLk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获客/douyinconnect.py index 5f867db..27a4ab3 100644 --- a/py1/获客/douyinconnect.py +++ b/py1/获客/douyinconnect.py @@ -1,11 +1,12 @@ from typing import List - +import time import mysql import mysql.connector import csv + def hello(): import quchong - qc() + quchong.qu() db_config = { 'host': 'localhost', 'user': 'root', @@ -27,6 +28,17 @@ def hello(): print("数据导入成功!") except mysql.connector.Error as err: print(f"数据导入失败: {err}") + try: + cursor.execute("SELECT zhanghao FROM douyinpinglunxinxi") + zhanghao_list = cursor.fetchall() + print("从数据库读取的 zhanghao:") + for zhanghao in zhanghao_list: + import zidongcaozuo + zidongcaozuo.zidong(zhanghao[0]) + time.sleep(30) + + except mysql.connector.Error as err: + print(f"读取 zhanghao 失败: {err}") finally: cursor.close() cnx.close() diff --git a/py1/获客/jiemian.py b/py1/获客/jiemian.py new file mode 100644 index 0000000..489e1df --- /dev/null +++ b/py1/获客/jiemian.py @@ -0,0 +1,30 @@ +from tkinter import Tk, Label, Entry, Button, StringVar, messagebox +import 抖音 + +def start_fetch(): + url = url_var.get() + cookie = cookie_var.get() + if url and cookie: + # 调用 douyin.py 中的函数,并传递 URL 和 Cookie + 抖音.chuancan(url, cookie) + else: + messagebox.showwarning("警告", "请输入URL和Cookie") + +# 创建 GUI +root = Tk() +root.title("抖音评论抓取") + +# URL 标签和输入框 +Label(root, text="URL:").grid(row=0, column=0, padx=10, pady=10) +url_var = StringVar() +Entry(root, textvariable=url_var, width=50).grid(row=0, column=1, padx=10, pady=10) + +# Cookie 标签和输入框 +Label(root, text="Cookie:").grid(row=1, column=0, padx=10, pady=10) +cookie_var = StringVar() +Entry(root, textvariable=cookie_var, width=50).grid(row=1, column=1, padx=10, pady=10) + +# 提交按钮 +Button(root, text="开始抓取", command=start_fetch).grid(row=2, columnspan=2, pady=10) + +root.mainloop() \ No newline at end of file diff --git a/py1/获客/quchong.py b/py1/获客/quchong.py index f045ba5..9d6cfa3 100644 --- a/py1/获客/quchong.py +++ b/py1/获客/quchong.py @@ -1,5 +1,5 @@ import pandas as pd -def qc(): +def qu(): # 加载CSV文件 data = pd.read_csv('抖音评论.csv') @@ -8,3 +8,5 @@ def qc(): # 保存清理后的数据到新文件 data_cleaned.to_csv('抖音评论.csv', index=False) + print("去重成功") + diff --git a/py1/获客/zidongcaozuo.py b/py1/获客/zidongcaozuo.py index 830f040..59d6857 100644 --- a/py1/获客/zidongcaozuo.py +++ b/py1/获客/zidongcaozuo.py @@ -7,89 +7,108 @@ from selenium.webdriver.edge.service import Service from selenium.webdriver.edge.options import Options from selenium.webdriver.support.ui import WebDriverWait from selenium.common.exceptions import TimeoutException -options = webdriver.EdgeOptions() -#options.add_argument("--headless") -options.add_argument("--start-maximized") # 最大化窗口 -options.add_argument("--disable-notifications") # 禁用通知 - -options.add_argument("user-data-dir=C:/Users/JJM/AppData/Local/Microsoft/Edge/User Data/Default") # 使用本地用户数据目录 - -options.add_experimental_option("detach", True) - -driver_edge = webdriver.Edge(options=options) -cookies = driver_edge.get_cookies() -for cookie in cookies: - print(cookie) -my_url = "https://www.douyin.com/" - -driver_edge.get(my_url) -sleep(5) - -# x=driver_edge.find_element(By.XPATH,'//*[@id="login-pannel"]/div[2]') -# x.click() -# sleep(10) -# 模拟点击 - -# search_box = driver_edge.find_element(By.XPATH,'//*[@id="douyin-header"]/div[1]/header/div/div/div[1]/div/div[2]/div/div/input').send_keys('zy2752629612',Keys.ENTER) - -search_box = driver_edge.find_element(By.XPATH,'//input[@class="st2xnJtZ YIde9aUh"]') - -print(search_box) - -search_box.send_keys('zy2752629612',Keys.ENTER) - -sleep(5) -print('===========>111111111') - -handles = driver_edge.window_handles #获取当前浏览器的所有窗口句柄 -driver_edge.switch_to.window(handles[-1]) -divm = driver_edge.find_element(By.XPATH,'//div[@class="G8LTciwG"]/a') - -divm.click() -print('==============66666') - - - - -# sleep(10) -# driver_edge.execute_script("window.scrollTo(0, document.body.scrollHeight);") -# sleep(1) # 等待滚动效果 -#f=driver_edge.find_element(By.CLASS_NAME,'B3AsdZT9 BMJLsW6X').click() -# elements = driver_edge.find_elements(By.XPATH, "//*") -# print(elements) - # 检查每个元素是否可见 -# for element in elements: -# if element.is_displayed(): -# print(f"元素 {element.tag_name} 可见") -# else: -# print(f"元素 {element.tag_name} 不可见") -# driver_edge.execute_script("arguments[0].style.display = 'block'; arguments[0].style.visibility = 'visible';", element) - - -# try: -# # 等待元素可见,超时设置为5秒 -# WebDriverWait(driver_edge, 1).until( -# EC.visibility_of(element) -# ) -# print(f"元素 {element.tag_name} 现在可见") -# except TimeoutException: -# print(f"元素 {element.tag_name} 仍然不可见") -# driver_edge.execute_script("arguments[0].scrollIntoView(true);", element) -# sleep(1) # 等待滚动效果 - -# # 再次检查元素是否可见 -# if element.is_displayed(): -# print("元素现在可见") -# else: -# print("元素仍不可见") -sleep(10) -handles = driver_edge.window_handles #获取当前浏览器的所有窗口句柄 -driver_edge.switch_to.window(handles[-1]) -print('==============66666') -h=driver_edge.find_element(By.XPATH,'//div[@class="hLIm2dFu"]/button[2]') -h.click() -b=driver_edge.find_element(By.XPATH,'//div[@class="c8uBfaOs"]/div[@class="public-DraftEditorPlaceholder-inner"]') -b.send_keys('zy2752629612',Keys.ENTER) - -# # 关闭浏览器 -# driver_edge.quit() \ No newline at end of file +def zidong(zhanghao): + options = webdriver.EdgeOptions() + #options.add_argument("--headless") + options.add_argument("--start-maximized") # 最大化窗口 + options.add_argument("--disable-notifications") # 禁用通知 + + options.add_argument("user-data-dir=C:/Users/JJM/AppData/Local/Microsoft/Edge/User Data/Default") # 使用本地用户数据目录 + + options.add_experimental_option("detach", True) + + driver_edge = webdriver.Edge(options=options) + cookies = driver_edge.get_cookies() + for cookie in cookies: + print(cookie) + my_url = "https://www.douyin.com/" + + driver_edge.get(my_url) + sleep(5) + + # x=driver_edge.find_element(By.XPATH,'//*[@id="login-pannel"]/div[2]') + # x.click() + # sleep(10) + # 模拟点击 + + # search_box = driver_edge.find_element(By.XPATH,'//*[@id="douyin-header"]/div[1]/header/div/div/div[1]/div/div[2]/div/div/input').send_keys('zy2752629612',Keys.ENTER) + + search_box = driver_edge.find_element(By.XPATH,'//input[@class="st2xnJtZ YIde9aUh"]') + + print(search_box) + #输入账号 + search_box.send_keys(zhanghao,Keys.ENTER) + + sleep(5) + print('===========>111111111') + + handles = driver_edge.window_handles #获取当前浏览器的所有窗口句柄 + driver_edge.switch_to.window(handles[-1]) + divm = driver_edge.find_element(By.XPATH,'//div[@class="G8LTciwG"]/a') + + divm.click() + print('==============66666') + + + + + # sleep(10) + # driver_edge.execute_script("window.scrollTo(0, document.body.scrollHeight);") + # sleep(1) # 等待滚动效果 + #f=driver_edge.find_element(By.CLASS_NAME,'B3AsdZT9 BMJLsW6X').click() + # elements = driver_edge.find_elements(By.XPATH, "//*") + # print(elements) + # 检查每个元素是否可见 + # for element in elements: + # if element.is_displayed(): + # print(f"元素 {element.tag_name} 可见") + # else: + # print(f"元素 {element.tag_name} 不可见") + # driver_edge.execute_script("arguments[0].style.display = 'block'; arguments[0].style.visibility = 'visible';", element) + + + # try: + # # 等待元素可见,超时设置为5秒 + # WebDriverWait(driver_edge, 1).until( + # EC.visibility_of(element) + # ) + # print(f"元素 {element.tag_name} 现在可见") + # except TimeoutException: + # print(f"元素 {element.tag_name} 仍然不可见") + # driver_edge.execute_script("arguments[0].scrollIntoView(true);", element) + # sleep(1) # 等待滚动效果 + + # # 再次检查元素是否可见 + # if element.is_displayed(): + # print("元素现在可见") + # else: + # print("元素仍不可见") + sleep(5) + handles = driver_edge.window_handles #获取当前浏览器的所有窗口句柄 + driver_edge.switch_to.window(handles[-1]) + print('==============66666') + sleep(5) + h=driver_edge.find_element(By.XPATH,'//div[@class="hLIm2dFu"]/button[2]') + h.click() + sleep(5) + divn = driver_edge.find_element(By.XPATH,'//div[@class="notranslate public-DraftEditor-content"]') + sleep(3) + divn.send_keys('6666666666',Keys.ENTER) + sleep(3) + spans = driver_edge.find_element(By.XPATH,'//span[@class="sCp7KhBv EWT1TDgs e2e-send-msg-btn"]') + spans.click() + # handles = driver_edge.window_handles #获取当前浏览器的所有窗口句柄 + # print(handles) + # driver_edge.switch_to.window(handles[-1]) + # print('==============66666') + # sleep(2) + # 这个是什么 ↓ + # b=driver_edge.find_element(By.XPATH,'//div[@class="CrZg1T3k OJQKO5KA"]/*') + # print(b) + # b.send_keys('zy2752629612',Keys.ENTER) + + #b.send_keys('zy2752629612',Keys.ENTER) + #//*[@id="island_b69f5"]/div/ul[2]/div/li/div/div/div[3]/div/div/div[2]/div/div[3]/div/div[2]/div[1]/div[1]/div/div/div[2]/div/div/div/div + # # 关闭浏览器 + # driver_edge.quit() +zidong('zy2752629612') \ No newline at end of file diff --git a/py1/获客/抖音.py b/py1/获客/抖音.py index ebc8ba9..0766699 100644 --- a/py1/获客/抖音.py +++ b/py1/获客/抖音.py @@ -7,24 +7,24 @@ import glob from time import sleep f=open('抖音评论.csv',mode='a',encoding='utf-8',newline='') csv_writer=csv.DictWriter(f,fieldnames=[ - '昵称', - '账号', - '评论', + '昵称', + '账号', + '评论', ]) csv_writer.writeheader() #评论接口 -url = 'https://www.douyin.com/aweme/v1/web/comment/list/?device_platform=webapp&aid=6383&channel=channel_pc_web&aweme_id=7368527269490445604&cursor=0&count=20&item_type=0&insert_ids=&whale_cut_token=&cut_version=1&rcFT=&update_version_code=170400&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1280&screen_height=720&browser_language=zh-CN&browser_platform=Win32&browser_name=Edge&browser_version=125.0.0.0&browser_online=true&engine_name=Blink&engine_version=125.0.0.0&os_name=Windows&os_version=10&cpu_core_num=8&device_memory=8&platform=PC&downlink=0.35&effective_type=3g&round_trip_time=800&webid=7346532852764591631&verifyFp=verify_lwlm1u72_stNCFCId_qzbH_4cpL_9Iep_AqW2XPQog7ma&fp=verify_lwlm1u72_stNCFCId_qzbH_4cpL_9Iep_AqW2XPQog7ma&msToken=BUDTdDbl3B85-cq712EQUfsoVxrmh7Xns1q17Z7JrcXxmqcc4yjx0qHJZosee8R1NtVQs-S70zcxv8VsusWsalpiXxdLwrwumnjrIhjBATZZh2wXhUDif-17&a_bogus=m6mhQmghmEVNXDyh56ALfY3q6-33Ym8r0trEMD2fsnfl1y39HMOO9exYXkzvwnfjLG%2FlIeujy4hbYN9krQA70qwfHuix%2F2ohmDSkKl5Q5xSSs1XJtyUgntsNmktUCec2-i-lrOXMoX1HFbSd09oHmhK4bIOwu3GMSf%3D%3D' +url = 'https://www.douyin.com/aweme/v1/web/comment/list/?device_platform=webapp&aid=6383&channel=channel_pc_web&aweme_id=7298556078936116514&cursor=0&count=20&item_type=0&insert_ids=&whale_cut_token=&cut_version=1&rcFT=&update_version_code=170400&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1280&screen_height=720&browser_language=zh-CN&browser_platform=Win32&browser_name=Edge&browser_version=125.0.0.0&browser_online=true&engine_name=Blink&engine_version=125.0.0.0&os_name=Windows&os_version=10&cpu_core_num=8&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=150&webid=7346532852764591631&msToken=5UeofHyLN4vyyGq9woOODNkxC-qSLAvZGPfLpmC1U8hLFZ-C8mpelKyz2Di3RhGb0iTeNI0vTUS9_CbU5T75F349_Mg45jJKpLVqrTa_DiZhOtUrifZAKxoT&a_bogus=D7mh%2FdhvDEITDfyk5IALfY3q6RB3YmMv0CPYMD2f1dflTL39HMT59exYUMwv-zfjLG%2FlIeujy4hbYN9krQVJ8ZwfHu4L%2F2oZsES2Kl2Q5xSSs1XJtyUgntsNmktUCec2-i-lrOXMoh1HFmug09oHmhK4bIOwu3GMEE%3D%3D' headers={ -'Referer':'https://www.douyin.com/search/%E7%BE%8A%E8%82%89%E6%89%B9%E5%8F%91?aid=037a1fc5-7500-415f-9cb4-056533ed2a37&modal_id=7355745553893870874&type=general', -'cookie':'LOGIN_STATUS=1; store-region=cn-hn; store-region-src=uid; my_rd=2; __live_version__=%221.1.1.4879%22; ttwid=1%7Cj1y2rrK1xocvz8_dWNVIq9GJ1UUkc3qyI3unO5Hnz7c%7C1710497985%7C0580bd3d607011ab36c5240383d9941e485699343a9be647cab7b4e4877837e3; xgplayer_user_id=785850983213; bd_ticket_guard_client_web_domain=2; SEARCH_RESULT_LIST_TYPE=%22single%22; dy_swidth=1280; dy_sheight=720; s_v_web_id=verify_lwlm1u72_stNCFCId_qzbH_4cpL_9Iep_AqW2XPQog7ma; passport_csrf_token=58820e3ccfd2a4c8d213c627c8bfcbf2; passport_csrf_token_default=58820e3ccfd2a4c8d213c627c8bfcbf2; FORCE_LOGIN=%7B%22videoConsumedRemainSeconds%22%3A180%2C%22isForcePopClose%22%3A1%7D; n_mh=O0Ud012BYDa2zc36g8-pEsT4HQkknDbOdmVfd9MRc2k; publish_badge_show_info=%220%2C0%2C0%2C1716611360297%22; _bd_ticket_crypt_doamin=2; __security_server_data_status=1; download_guide=%223%2F20240525%2F1%22; pwa2=%220%7C0%7C3%7C1%22; volume_info=%7B%22isUserMute%22%3Afalse%2C%22isMute%22%3Atrue%2C%22volume%22%3A0.782%7D; strategyABtestKey=%221716913486.671%22; csrf_session_id=2fa734583c90f0008132a62ef1d35849; WallpaperGuide=%7B%22showTime%22%3A1716647836149%2C%22closeTime%22%3A0%2C%22showCount%22%3A1%2C%22cursor1%22%3A38%2C%22cursor2%22%3A0%7D; passport_assist_user=CkHDnwHJFqV3Hmnr_wWu_20uRY76STzf3Yk_C_17WKJ4of6iixzXSx5CYUF7diaCEN03znCNtHep5en_763hzsNyphpKCjypXf-C-sbpu6h1mWGCnh-rmG2mmxagdqRbRzhoNFr0meuqwYMCu_2RxfyI7bB04PdvZ8TMTLGWba9DBC4Q08bSDRiJr9ZUIAEiAQOh_u6X; sso_uid_tt=b3b014e9237e24a2434fcc69284c9e97; sso_uid_tt_ss=b3b014e9237e24a2434fcc69284c9e97; toutiao_sso_user=b9e365d2df3a7c6ba5499448985f61c7; toutiao_sso_user_ss=b9e365d2df3a7c6ba5499448985f61c7; sid_ucp_sso_v1=1.0.0-KGYxZDViZTQxNDIwYWQ0NmI3ZWRkOWE5MWZkZjM5YjAzMmU1YmNmYWEKHwjUmfCgqMzoAhCSp9qyBhjvMSAMMNmDoaEGOAZA9AcaAmhsIiBiOWUzNjVkMmRmM2E3YzZiYTU0OTk0NDg5ODVmNjFjNw; ssid_ucp_sso_v1=1.0.0-KGYxZDViZTQxNDIwYWQ0NmI3ZWRkOWE5MWZkZjM5YjAzMmU1YmNmYWEKHwjUmfCgqMzoAhCSp9qyBhjvMSAMMNmDoaEGOAZA9AcaAmhsIiBiOWUzNjVkMmRmM2E3YzZiYTU0OTk0NDg5ODVmNjFjNw; passport_auth_status=e86684cdf98b870d7eccf74c2242c1fc%2C19d9f08e07de1935f52dedcb194265de; passport_auth_status_ss=e86684cdf98b870d7eccf74c2242c1fc%2C19d9f08e07de1935f52dedcb194265de; uid_tt=7d49bc6824c58d434d292eb027c8021a; uid_tt_ss=7d49bc6824c58d434d292eb027c8021a; sid_tt=c93b600d87e77460e20cda04620f4809; sessionid=c93b600d87e77460e20cda04620f4809; sessionid_ss=c93b600d87e77460e20cda04620f4809; _bd_ticket_crypt_cookie=4200935d4c9d21af23023ca3e5718554; sid_guard=c93b600d87e77460e20cda04620f4809%7C1716949911%7C5183997%7CSun%2C+28-Jul-2024+02%3A31%3A48+GMT; sid_ucp_v1=1.0.0-KDY3YmQzNDA0N2M1ZWE5ZmU1ZWFiMTgyNWRkNjliMjc4ZDY3N2U1MTkKGwjUmfCgqMzoAhCXp9qyBhjvMSAMOAZA9AdIBBoCaGwiIGM5M2I2MDBkODdlNzc0NjBlMjBjZGEwNDYyMGY0ODA5; ssid_ucp_v1=1.0.0-KDY3YmQzNDA0N2M1ZWE5ZmU1ZWFiMTgyNWRkNjliMjc4ZDY3N2U1MTkKGwjUmfCgqMzoAhCXp9qyBhjvMSAMOAZA9AdIBBoCaGwiIGM5M2I2MDBkODdlNzc0NjBlMjBjZGEwNDYyMGY0ODA5; douyin.com; device_web_cpu_core=8; device_web_memory_size=8; architecture=amd64; xg_device_score=7.385531388768509; home_can_add_dy_2_desktop=%220%22; stream_player_status_params=%22%7B%5C%22is_auto_play%5C%22%3A1%2C%5C%22is_full_screen%5C%22%3A0%2C%5C%22is_full_webscreen%5C%22%3A0%2C%5C%22is_mute%5C%22%3A1%2C%5C%22is_speed%5C%22%3A1%2C%5C%22is_visible%5C%22%3A1%7D%22; passport_fe_beating_status=true; odin_tt=16f044c9bd17a88c3c02d2a39992fb90fea29dd69d929ebf9649920fff66a45b82db05491ed9a1cee677dc686ce3535720482bf0b24e29a5e727057c1aafba4e; FOLLOW_NUMBER_YELLOW_POINT_INFO=%22MS4wLjABAAAAsHY3M7WCvAd6-fwDR0tYP32MvxlSPgEfD3dF69gvt3Wg7bkb3YHFIkTg0hifLIWT%2F1716998400000%2F1716949915651%2F0%2F1716964466935%22; __ac_nonce=06656d8c2007c18889bb9; __ac_signature=_02B4Z6wo00f01r4zzQgAAIDDYWg-R7KOY1K-E8mAAMnm3nFmdeA72UBASw1nJi5NnQUyLIHzWOJ9y1GtE1cx8RHUtRM0ECXwp1sbFgNxPFu0kVAhV3spBRLkkNnSj9Z.C4nyRdop7nTjQvnmf8; IsDouyinActive=true; stream_recommend_feed_params=%22%7B%5C%22cookie_enabled%5C%22%3Atrue%2C%5C%22screen_width%5C%22%3A1280%2C%5C%22screen_height%5C%22%3A720%2C%5C%22browser_online%5C%22%3Atrue%2C%5C%22cpu_core_num%5C%22%3A8%2C%5C%22device_memory%5C%22%3A8%2C%5C%22downlink%5C%22%3A0.35%2C%5C%22effective_type%5C%22%3A%5C%223g%5C%22%2C%5C%22round_trip_time%5C%22%3A800%7D%22; bd_ticket_guard_client_data=eyJiZC10aWNrZXQtZ3VhcmQtdmVyc2lvbiI6MiwiYmQtdGlja2V0LWd1YXJkLWl0ZXJhdGlvbi12ZXJzaW9uIjoxLCJiZC10aWNrZXQtZ3VhcmQtcmVlLXB1YmxpYy1rZXkiOiJCTlplYVlVb2N5Z1ZqakNXYnptL0RNN1h6OE94VWJ6ZVVETkFBWVVvRFJEMlJTSkxFRkJQOVhjazlCSzd6K0dUMzBnTlBwKzlwWnZ6a0hoQXRrWEdabUE9IiwiYmQtdGlja2V0LWd1YXJkLXdlYi12ZXJzaW9uIjoxfQ%3D%3D; FOLLOW_LIVE_POINT_INFO=%22MS4wLjABAAAAsHY3M7WCvAd6-fwDR0tYP32MvxlSPgEfD3dF69gvt3Wg7bkb3YHFIkTg0hifLIWT%2F1716998400000%2F0%2F1716967627978%2F0%22; msToken=GforqsysdNF59KAHqxdbrTMQeuKWb4QAM2VZPKM-qh3TcoiyPRKS0O8rWin1tDqOzweZSIf_F5_OjAc1cPown5QluqMFcnNqc_E8hpWoaXrh-LW-80bZrqmC', -'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0' +'Referer':'https://www.douyin.com/search/%E7%88%B1%E7%9A%84%E6%80%92%E7%81%AB?aid=03d0197f-e578-4920-83f0-44173ee93c0c&modal_id=7298556078936116514&type=general', +'cookie':'LOGIN_STATUS=1; store-region=cn-hn; store-region-src=uid; my_rd=2; __live_version__=%221.1.1.4879%22; ttwid=1%7Cj1y2rrK1xocvz8_dWNVIq9GJ1UUkc3qyI3unO5Hnz7c%7C1710497985%7C0580bd3d607011ab36c5240383d9941e485699343a9be647cab7b4e4877837e3; xgplayer_user_id=785850983213; bd_ticket_guard_client_web_domain=2; SEARCH_RESULT_LIST_TYPE=%22single%22; dy_swidth=1280; dy_sheight=720; s_v_web_id=verify_lwlm1u72_stNCFCId_qzbH_4cpL_9Iep_AqW2XPQog7ma; passport_csrf_token=58820e3ccfd2a4c8d213c627c8bfcbf2; passport_csrf_token_default=58820e3ccfd2a4c8d213c627c8bfcbf2; FORCE_LOGIN=%7B%22videoConsumedRemainSeconds%22%3A180%2C%22isForcePopClose%22%3A1%7D; _bd_ticket_crypt_doamin=2; __security_server_data_status=1; download_guide=%223%2F20240525%2F1%22; csrf_session_id=954f5909548272d718a3ecbdb0fd9df8; douyin.com; device_web_cpu_core=8; device_web_memory_size=8; architecture=amd64; passport_assist_user=CkGTU8poo6Xij7PpTE-fUre1nhzcRBFJYHRkb7NQSNTQ9iNdua_sq5fW3SH3UswucQWWgGMnSPMP1bB1ILAbFI0CWBpKCjxGylE8zOMF-zm4w_eR6Pi_pX-ZzeDFKYIrlSqAG5E4ICB0TXX9rIwP8tdroe8GAZc1jHqmwTdNPdMWwSIQp_nSDRiJr9ZUIAEiAQN-VLfr; n_mh=eRTYt2yhIheBvqQdvgMfXadK0QnaYOp5didcMz0Ww-o; sso_uid_tt=9ed08f5e09478ad14f5c7040302e1eb9; sso_uid_tt_ss=9ed08f5e09478ad14f5c7040302e1eb9; toutiao_sso_user=f9d9c4f781e3bab9ac19a8f4a3100824; toutiao_sso_user_ss=f9d9c4f781e3bab9ac19a8f4a3100824; sid_ucp_sso_v1=1.0.0-KDkyYTIxMjA2MDJiYTc2MWVkMzg2MzZkMDViMGZmMDY2ZmE5MjA4N2IKHwjUmfCgqMzoAhDZgPKyBhjvMSAMMNmDoaEGOAZA9AcaAmxxIiBmOWQ5YzRmNzgxZTNiYWI5YWMxOWE4ZjRhMzEwMDgyNA; ssid_ucp_sso_v1=1.0.0-KDkyYTIxMjA2MDJiYTc2MWVkMzg2MzZkMDViMGZmMDY2ZmE5MjA4N2IKHwjUmfCgqMzoAhDZgPKyBhjvMSAMMNmDoaEGOAZA9AcaAmxxIiBmOWQ5YzRmNzgxZTNiYWI5YWMxOWE4ZjRhMzEwMDgyNA; passport_auth_status=d9b57afe2b5a9d46bf94fe6be3fbff5e%2Ce86684cdf98b870d7eccf74c2242c1fc; passport_auth_status_ss=d9b57afe2b5a9d46bf94fe6be3fbff5e%2Ce86684cdf98b870d7eccf74c2242c1fc; uid_tt=0f66b8fa9bc5d113e984d09b1d834684; uid_tt_ss=0f66b8fa9bc5d113e984d09b1d834684; sid_tt=d8a420e331706f83d5ca7c6ee82cd4c8; sessionid=d8a420e331706f83d5ca7c6ee82cd4c8; sessionid_ss=d8a420e331706f83d5ca7c6ee82cd4c8; publish_badge_show_info=%220%2C0%2C0%2C1717338205811%22; _bd_ticket_crypt_cookie=4dbd1a3b0950e14f64ff55ec49f90e45; sid_guard=d8a420e331706f83d5ca7c6ee82cd4c8%7C1717338207%7C5183997%7CThu%2C+01-Aug-2024+14%3A23%3A24+GMT; sid_ucp_v1=1.0.0-KDg2ZGFkNmFhM2M3NTkzZDg2Yjk1YjVkMTkxYjU1NWZmNjVhMThjZTYKGwjUmfCgqMzoAhDfgPKyBhjvMSAMOAZA9AdIBBoCbGYiIGQ4YTQyMGUzMzE3MDZmODNkNWNhN2M2ZWU4MmNkNGM4; ssid_ucp_v1=1.0.0-KDg2ZGFkNmFhM2M3NTkzZDg2Yjk1YjVkMTkxYjU1NWZmNjVhMThjZTYKGwjUmfCgqMzoAhDfgPKyBhjvMSAMOAZA9AdIBBoCbGYiIGQ4YTQyMGUzMzE3MDZmODNkNWNhN2M2ZWU4MmNkNGM4; EnhanceDownloadGuide=%220_0_0_0_1_1717338361%22; FRIEND_NUMBER_RED_POINT_INFO=%22MS4wLjABAAAAsHY3M7WCvAd6-fwDR0tYP32MvxlSPgEfD3dF69gvt3Wg7bkb3YHFIkTg0hifLIWT%2F1717430400000%2F1717404179615%2F0%2F0%22; xg_device_score=7.658235294117647; stream_player_status_params=%22%7B%5C%22is_auto_play%5C%22%3A1%2C%5C%22is_full_screen%5C%22%3A0%2C%5C%22is_full_webscreen%5C%22%3A0%2C%5C%22is_mute%5C%22%3A1%2C%5C%22is_speed%5C%22%3A1%2C%5C%22is_visible%5C%22%3A0%7D%22; strategyABtestKey=%221717430892.71%22; FOLLOW_NUMBER_YELLOW_POINT_INFO=%22MS4wLjABAAAAsHY3M7WCvAd6-fwDR0tYP32MvxlSPgEfD3dF69gvt3Wg7bkb3YHFIkTg0hifLIWT%2F1717516800000%2F0%2F1717464393954%2F0%22; pwa2=%220%7C0%7C3%7C1%22; WallpaperGuide=%7B%22showTime%22%3A1717401975356%2C%22closeTime%22%3A0%2C%22showCount%22%3A3%2C%22cursor1%22%3A118%2C%22cursor2%22%3A0%2C%22hoverTime%22%3A1717256760346%7D; volume_info=%7B%22isUserMute%22%3Afalse%2C%22isMute%22%3Atrue%2C%22volume%22%3A0.782%7D; passport_fe_beating_status=true; stream_recommend_feed_params=%22%7B%5C%22cookie_enabled%5C%22%3Atrue%2C%5C%22screen_width%5C%22%3A1280%2C%5C%22screen_height%5C%22%3A720%2C%5C%22browser_online%5C%22%3Atrue%2C%5C%22cpu_core_num%5C%22%3A8%2C%5C%22device_memory%5C%22%3A8%2C%5C%22downlink%5C%22%3A10%2C%5C%22effective_type%5C%22%3A%5C%224g%5C%22%2C%5C%22round_trip_time%5C%22%3A150%7D%22; __ac_nonce=0665f233800997e0784ab; __ac_signature=_02B4Z6wo00f01713bbAAAIDCYiye.nqmZK-9V2kAAIkLil267K7I.RdxYpq1ylx1T.Ryq8xoVSjqacrgXIDiTfmNTUTJRNmC8XgVD5Kjbljer-ByunCzBiKCc9yIO71ba-US1nW5McraC2xQda; FOLLOW_LIVE_POINT_INFO=%22MS4wLjABAAAAsHY3M7WCvAd6-fwDR0tYP32MvxlSPgEfD3dF69gvt3Wg7bkb3YHFIkTg0hifLIWT%2F1717516800000%2F0%2F0%2F1717511569362%22; home_can_add_dy_2_desktop=%221%22; bd_ticket_guard_client_data=eyJiZC10aWNrZXQtZ3VhcmQtdmVyc2lvbiI6MiwiYmQtdGlja2V0LWd1YXJkLWl0ZXJhdGlvbi12ZXJzaW9uIjoxLCJiZC10aWNrZXQtZ3VhcmQtcmVlLXB1YmxpYy1rZXkiOiJCTlplYVlVb2N5Z1ZqakNXYnptL0RNN1h6OE94VWJ6ZVVETkFBWVVvRFJEMlJTSkxFRkJQOVhjazlCSzd6K0dUMzBnTlBwKzlwWnZ6a0hoQXRrWEdabUE9IiwiYmQtdGlja2V0LWd1YXJkLXdlYi12ZXJzaW9uIjoxfQ%3D%3D; odin_tt=8c00d2ad8b2502257ff5100209bb406ce884716b8a92d9bbdf26d0a7a8a26a11a1e05076d0ed9303ab2578c1a5b50981; IsDouyinActive=true; msToken=QOJTILLohvqFzMYZ4T1aYPrVkTk23qgpJZ82xr26R5U3UxObl7dsxSTRAPtvDxDGGhrbETTUVkyFbeQV6QBTRCRjj3bxTNQzRGaEksUf2r2vTxnmxMowdML9', +'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0' } response = requests.get(url=url,headers=headers,) @@ -36,14 +36,15 @@ except json.JSONDecodeError: print("JSON 解码失败,请检查响应是否为有效的 JSON 格式。")''' #response_text = response.json()['comments'] #print(response.text) - for shuju in response.json()['comments']: + + user_list = shuju['user'] dit={ - '昵称':user_list['nickname'], - '账号':user_list['short_id'], + '昵称':user_list['nickname'], + '账号':user_list['short_id'], "评论":shuju['text'] } @@ -51,26 +52,26 @@ for shuju in response.json()['comments']: -def check_for_csv_files(PY1): - """ - 检查指定目录下是否存在.csv文件。 +# def check_for_csv_files(PY1): +# """ +# 检查指定目录下是否存在.csv文件。 - :param directory: 要检查的目录路径 - :return: 如果找到.csv文件返回True,否则返回False - """ - # 使用glob模块匹配目录下的所有.csv文件 - csv_files = glob.glob(os.path.join(PY1, '*.csv')) +# :param directory: 要检查的目录路径 +# :return: 如果找到.csv文件返回True,否则返回False +# """ +# # 使用glob模块匹配目录下的所有.csv文件 +# csv_files = glob.glob(os.path.join(PY1, '*.csv')) - # 如果找到.csv文件,则csv_files列表不为空,返回True - return bool(csv_files) +# # 如果找到.csv文件,则csv_files列表不为空,返回True +# return bool(csv_files) + +# # 示例:检查当前目录下是否存在.csv文件 +# current_dir = os.getcwd() +# if check_for_csv_files(current_dir): +# print("存在.csv文件。") +# import douyinconnect +# douyinconnect() +# else: +# print("没有找到.csv文件。") -# 示例:检查当前目录下是否存在.csv文件 -current_dir = os.getcwd() -if check_for_csv_files(current_dir): - print("存在.csv文件。") - import douyinconnect - hello() -else: - print("没有找到.csv文件。") -sleep(2) -import quchong +