CustomerAcquisition 6 months ago
parent 771692052c
commit e5e2e117ea

@ -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()

@ -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,我愿意嘿嘿嘿[呲牙]

1 昵称 账号 评论
11 嘎兰花儿 1103292172 哈哈,太知道了,我不提醒,我家夫君两天都不会干,我提醒了,他就说我本来就会去干的,曾经大夏天让他自己吃的西瓜皮放茶几上两天!
12 MAGO party气球派对布置 1162629054 这么好的解说不能下载[捂脸]我还想发给家庭群看看呢
13 白云无尽时 2251181178 老师能读一下李娟的作品《我的阿勒泰》吗,谢谢!
14 大志爸爸 68830320 教育的本质不在于灌输,在于点燃火焰! 学习了 教育的本质不在于灌输,在于点燃火焰!学习了
Shameless 35598233242 哪怕你有99个白球,你摸到了黑球,那么你就只有黑球了。
15 㸚燚 Shameless 2801279137 35598233242 了不起的自驱力 哪怕你有99个白球,你摸到了黑球,那么你就只有黑球了。
16 疯癫小浪 㸚燚 29899141302 2801279137 我会整理下茶几,顺便看下有什么需要一起整理的。 了不起的自驱力
17 随便打的 疯癫小浪 58057786825 29899141302 这个好,我要用这本书开发一套课程 我会整理下茶几,顺便看下有什么需要一起整理的。
18 季易安 随便打的 36859095256 58057786825 以为是不略呢 这个好,我要用这本书开发一套课程
19 孟娜丽莎 季易安 853410475 36859095256 让孩子自己安排时间,孩子不会安排的,最后玩的都忘记了。学习这个事情是主动的,我小时候学习,从不用说,老师一边布置我一边写,每次学校都把作业完成了。 如果自己做好了,家长就不会说了。主要是孩子自身的原因,自己不主动 以为是不略呢
20 多多做得到 孟娜丽莎 1467070616 853410475 非常棒! 让孩子自己安排时间,孩子不会安排的,最后玩的都忘记了。学习这个事情是主动的,我小时候学习,从不用说,老师一边布置我一边写,每次学校都把作业完成了。如果自己做好了,家长就不会说了。主要是孩子自身的原因,自己不主动
21 多多做得到 1467070616 非常棒!
22 昵称 账号 评论
23 昵称 账号 评论
24 好听的名字 1396822405 第一个感觉老公是装的[九转大肠]
25 沧月 1048097576 这个是我的爱,其实在一起一辈子不吵架是不可能的,只是在吵架的时候或者过后能不能回想起他之前的好就是另外一回事儿,也会影响到后面还会不会在一起。[比心]
26 刘憨憨🍀 1340099500 纯爱版的悬溺
27 meteora 1047016341 下一个给我推的就是这个
28 「F。 1047851117 600块都要逃单?这群朋友物质和情义二者一个都没有
29 23.8万等人 885855025 故意拍摄的啊 大家爱看。
30 呆滞 58650318928 科幻片
31 乘风的 海浪 51175596404 是不看得不想结婚的都想结婚了
32 乱糟糟🐾 2946118630 第一个我建议这桌人全绝交就行了,一起喝酒喝完不送不说,别人都喝多睡着了,一桌没一个结账的[尬笑][尬笑][尬笑]什么朋友都是
33 安冉安乐 3717028503 你这媳妇做饭不要给我看,因为我不会。也不要给我老公,我怕他多想。
34 狂徒 45600071728 抖抖音看多了会得妄想症😳
35 无! 59244860271 大哥都看蒙了
36 海幸福 346083670 以前什么好的都想留给他顾不上自己最后……
37 Licia👱🏼‍♀️ 60476459398 我点了不感兴趣 我的老公不配 伤透心了
38 2231613459 2231613459 无效的社交不如在家陪老婆。
39 风吹过我的头发(搬砖版) 908114924 刚看了骑水泥封心又要让我裂开是吧[捂脸]
40 QWEN 174856020 第二个表演的尴尬死了
41 闻♥ 24576166963 内个,我不是在做梦吧?[抱抱你][一起加油]
42 十四阿哥 2843786537 第一个那个男人以后肯定不会再跟那些所谓的朋友一起喝酒了!
43 🦻♪(´不🉑话🦔de阿La斯加🐬 136094221 我愿意嘿嘿嘿[呲牙]

@ -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()

@ -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()

@ -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("去重成功")

@ -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()
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')

@ -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

Loading…
Cancel
Save