Skip to content

Commit 5d12c13

Browse files
committed
Merge remote-tracking branch 'github/main'
# Conflicts: # facebook/FBmain.py
2 parents b820563 + 0b27af0 commit 5d12c13

4 files changed

Lines changed: 19 additions & 15 deletions

File tree

FBver/FB_middle.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ def parse_bool(type_data):
3333

3434

3535
async def main(content0, content1):
36+
is_multiple_accounts = True
37+
multiple_accounts = 5
3638
app = QApplication.instance()
3739
if not app:
3840
app = QApplication(sys.argv)

facebook/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
regeditfile.reg
1+
regeditfile.reg
2+
/FB.json

facebook/FBmain.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ async def getusers(self):
626626
csv_writer.writerow(['userid', 'username', 'societiesid']) # 写入表头
627627
csv_writer.writerows(in_csv_data) # 写入数据
628628
print(f"爬取完成,共获取 {user_counter} 个用户信息")
629+
await self.robust_update_status("開始提交數據...")
629630
# 使用线程池执行数据库提交(避免阻塞主线程)
630631
loop = asyncio.get_event_loop()
631632
with ThreadPoolExecutor() as executor:
@@ -641,7 +642,7 @@ async def getusers(self):
641642
user_counter # 实际获取数量
642643
)
643644

644-
await self.robust_update_status(f"{csv_filename}数据提交完成")
645+
await self.robust_update_status(f"{csv_filename}數據提交完成")
645646
upend_time = datetime.datetime.now()
646647
db_manager.update_updata_table(self.device, len(users), upend_time)
647648
else:
@@ -761,6 +762,7 @@ async def getusers_fans(self):
761762
csv_writer.writerow(['userid', 'username', 'societiesid']) # 写入表头
762763
csv_writer.writerows(in_csv_data) # 写入数据
763764
print(f"爬取完成,共获取 {user_counter} 个用户信息")
765+
await self.robust_update_status("開始提交數據...")
764766
# 使用线程池执行数据库提交(避免阻塞主线程)
765767
loop = asyncio.get_event_loop()
766768
with ThreadPoolExecutor() as executor:
@@ -775,13 +777,14 @@ async def getusers_fans(self):
775777
self.groups_num, # 总粉丝数
776778
user_counter # 实际获取数量
777779
)
778-
await self.robust_update_status(f"{csv_filename}数据提交完成")
780+
await self.robust_update_status(f"{csv_filename}數據提交完成")
779781
upend_time = datetime.datetime.now()
780782
db_manager.update_updata_table(self.device, len(users), upend_time)
781783
else:
782784
print("無用戶")
783785

784786
async def getusers_like(self):
787+
await self.robust_update_status("開始獲取贊助帖子用戶...")
785788
await self.page.goto(url="https://www.facebook.com/", wait_until='load', timeout=50000)
786789
title = await self.page.title()
787790
if "Facebook" in title:
@@ -835,7 +838,7 @@ async def cycle_post(self, num_posts, like_count, seek_count):
835838
if element:
836839
await element.scroll_into_view_if_needed()
837840
print(f"第 {i} 个帖子")
838-
await self.robust_update_status(f"第 {i} 个帖子")
841+
await self.robust_update_status(f"第 {i} 個帖子")
839842
like_count, seek_count = await self.sponsor_like(selector, like_count, seek_count)
840843
# if like_count >= num_posts:
841844
# break
@@ -850,6 +853,7 @@ async def cycle_post(self, num_posts, like_count, seek_count):
850853
return like_count, seek_count
851854

852855
async def getusers_like_url(self, url):
856+
await self.robust_update_status("開始獲取指定貼文點贊用戶...")
853857
for i in range(len(url)):
854858
await self.page.goto(url=url[i], wait_until='load', timeout=50000)
855859

@@ -912,9 +916,6 @@ async def sponsor_like_click(self, selector):
912916

913917
async def get_sponsor_user(self):
914918
"""修正版:获取赞助帖子的点赞用户"""
915-
print("開始獲取贊助帖子用戶......")
916-
await self.robust_update_status("開始獲取贊助帖子用戶...")
917-
918919
# 初始化变量(移到循环外)
919920
previous_count = 0
920921
current_count = 0
@@ -1099,12 +1100,12 @@ async def dialog_(self):
10991100

11001101
if not page_size:
11011102
print("未找到页面窗口")
1102-
await self.robust_update_status(f"未找到弹窗")
1103+
await self.robust_update_status(f"未找到彈窗")
11031104
return
11041105

11051106
except Exception as e:
11061107
print(f"等待窗口出现时出错: {str(e)}")
1107-
await self.robust_update_status(f"等待弹窗出现时出错")
1108+
await self.robust_update_status(f"等待彈窗出現時出錯")
11081109
return
11091110
try:
11101111
# 获取弹窗的位置和大小
@@ -1117,7 +1118,7 @@ async def dialog_(self):
11171118
print(f"鼠标滚动,位置: ({center_x}, {center_y})")
11181119
except Exception as e:
11191120
print(f"鼠标滚动出错: {str(e)}")
1120-
await self.robust_update_status(f"鼠标滚动出错")
1121+
await self.robust_update_status(f"鼠標滾動出錯")
11211122

11221123
async def home_post(self):
11231124
await self.page.goto(url="https://www.facebook.com/", wait_until='load')

facebook/database_manager.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,12 @@ def insert_supportUser(self, userData: any) -> bool:
166166
userid, username, supportid = item
167167

168168
# 检查是否已存在相同的记录
169-
cursor.execute("SELECT COUNT(*) FROM SupportUser_copy1 WHERE userid = ? AND Supportid = ?",
169+
cursor.execute("SELECT COUNT(*) FROM SupportUser WHERE userid = ? AND Supportid = ?",
170170
userid, supportid)
171171
if cursor.fetchone()[0] == 0:
172172
# 不存在相同记录,执行插入
173173
query = """
174-
INSERT INTO SupportUser_copy1 (userid, username, Supportid)
174+
INSERT INTO SupportUser (userid, username, Supportid)
175175
VALUES (?, ?, ?)
176176
"""
177177
cursor.execute(query, userid, username, supportid)
@@ -202,12 +202,12 @@ def insert_post_info(self, post_info: any) -> bool:
202202
# 使用 UPSERT 操作(如果记录存在则更新,否则插入)
203203
cursor.execute(
204204
"""
205-
IF EXISTS (SELECT 1 FROM SupportInf_copy1 WHERE Supportid = ?)
206-
UPDATE SupportInf_copy1
205+
IF EXISTS (SELECT 1 FROM SupportInf WHERE Supportid = ?)
206+
UPDATE SupportInf
207207
SET number = number + ?, SupportName = ?
208208
WHERE Supportid = ?
209209
ELSE
210-
INSERT INTO SupportInf_copy1 (Supportid, SupportName, number)
210+
INSERT INTO SupportInf (Supportid, SupportName, number)
211211
VALUES (?, ?, ?)
212212
""",
213213
post_info['Supportid'],

0 commit comments

Comments
 (0)