简体   繁体   English

Telethon Python TypeError:__init__() 得到了一个意外的关键字参数“hash”

[英]Telethon Python TypeError: __init__() got an unexpected keyword argument 'hash'

hi i use this code for scraping members in telegram groups but error for GetDialogsRequest i use hash_id and remove hash as request but not worked parametr hash is argument in GetDialogsRequest嗨,我使用此代码来抓取电报组中的成员,但 GetDialogsRequest 出现错误

other parametrs其他参数

offset_date offset_id offset_peer limit hash exclude_pinned folder_id offset_date offset_id offset_peer limit hash exclude_pinned folder_id

from telethon import TelegramClient
from telethon.tl.functions.messages import GetDialogsRequest
from telethon.tl.types import InputPeerEmpty
import csv

api_id = 11111
api_hash = '2328378db8c4cf3a74cd1240eb16272f3'
phone = '+44000000000'
client = TelegramClient(phone, api_id, api_hash)

client.connect()
if not client.is_user_authorized():
    client.send_code_request(phone)
    client.sign_in(phone, input('Enter the code: '))


chats = []
last_date = None
chunk_size = 200
groups=[]

result = client(GetDialogsRequest(
             offset_date=last_date,
             offset_id=0,
             offset_peer=InputPeerEmpty(),
             limit=chunk_size,
             hash = 0
))
chats.extend(result.chats)

for chat in chats:
    try:
        if chat.megagroup== True:
            groups.append(chat)
    except:
        continue

print('Choose a group to scrape members from:')
i=0
for g in groups:
    print(str(i) + '- ' + g.title)
    i+=1

g_index = input("Enter a Number: ")
target_group=groups[int(g_index)]

print('Fetching Members...')
all_participants = []
all_participants = client.get_participants(target_group, aggressive=True)

print('Saving In file...')
with open("members.csv","w",encoding='UTF-8') as f:
    writer = csv.writer(f,delimiter=",",lineterminator="\n")
    writer.writerow(['username','user id', 'access hash','name','group', 'group id'])
    for user in all_participants:
        if user.username:
            username= user.username
        else:
            username= ""
        if user.first_name:
            first_name= user.first_name
        else:
            first_name= ""
        if user.last_name:
            last_name= user.last_name
        else:
            last_name= ""
        name= (first_name + ' ' + last_name).strip()
        writer.writerow([username,user.id,user.access_hash,name,target_group.title, target_group.id])      
print('Members scraped successfully.')

and get result并得到结果

TypeError: __init__() got an unexpected keyword argument 'hash'

what is the problem ?问题是什么 ?

Contrary to the error, GetDialogsRequest.__init__ does have a hash argument.与错误相反, GetDialogsRequest.__init__确实有一个hash参数。

Perhaps you are using an older version of telethon.也许您使用的是旧版本的 Telethon。 Try to upgrade it.尝试升级它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TypeError at '' __init__() 得到一个意外的关键字参数 '' - TypeError at '' __init__() got an unexpected keyword argument '' Python openpyxl TypeError:__init __()获得了意外的关键字参数'pivotButton' - Python openpyxl TypeError: __init__() got an unexpected keyword argument 'pivotButton' Python Flask - TypeError: __init__() 得到了一个意外的关键字参数“lable” - Python Flask - TypeError: __init__() got an unexpected keyword argument 'lable' Python 3.5:TypeError:__ init __()得到了一个意外的关键字参数'nosigint' - Python 3.5 : TypeError: __init__() got an unexpected keyword argument 'nosigint' python请求:TypeError:__ init __()得到一个意外的关键字参数'proxies' - python requests: TypeError: __init__() got an unexpected keyword argument 'proxies' 为什么我得到了一个 TypeError: __init__() 在 python sklearn 中得到了一个意外的关键字参数“outer_cv”? - Why I got an TypeError: __init__() got an unexpected keyword argument 'outer_cv' in python sklearn? Scrapy错误:TypeError:__ init __()得到一个意外的关键字参数'deny' - Scrapy Error: TypeError: __init__() got an unexpected keyword argument 'deny' TypeError:__init __()得到了意外的关键字参数错误 - TypeError: __init__() got an unexpected keyword argument error TypeError:__ init __()在argparse中有一个意外的关键字参数'type' - TypeError: __init__() got an unexpected keyword argument 'type' in argparse 图片/创建时发生TypeError-__init __()得到了意外的关键字参数'save' - TypeError at images/create - __init__() got an unexpected keyword argument 'save'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM