避免在 IMDb 名称搜索中出现相似名称

发布于 2025-01-15 20:48:59 字数 1194 浏览 3 评论 0原文

我的目标是使用 IMDb 姓名搜索来获取与我要查找的姓​​名完全相同的人的 ID。不幸的是,我也用这个代码得到了所有相似的名字。

import imdb

# creating instance of IMDb
ia = imdb.IMDb()

# list of names
names = ["Paul Alexander Abel", "Viktor Abel", "Heinz Abosch"]

# searching the name
for n in names:
    print("-----", n, "-----")
    search = ia.search_person(n)

# loop for printing the name and id
    for i in range(len(search)):
    # getting the id
        id = search[i].personID
        print(search[i]['name'] + " : " + id)
# output:
----- Viktor Abel -----
Viktor Vrabec : 0903968
Viktor Brabec : 0102632
Viktor Abroi : 6636627
Viktor Absolutov : 5153732
Viktoriia Bessarab : 10441797
Viktoriya Brabec : 13413004
Viktor Abolduyev : 0008850
Viktor Abramov : 12453191
Viktor Abramov : 11944753
Viktor Abakumov : 12360818
Viktor Abramovskiy : 3277781
Viktor Abramyan : 8311765
Viktor Abrosimov : 1480489
Viktoriya Belyakova : 11558430
Viktoriya Belova : 1495496
Viktoriya Belyaeva : 5274884
Viktoria Believein : 3637309
Viktoria Belovonskaya : 10260945
Viktoriya Belyavskaya : 10267906
Viktorie Isabella Ter-Akopow : 9422886
----- Heinz Abosch -----
Heinz Ambrosch : 0024376

有办法改变吗?

My goal is to use the IMDb name search to get the ID for a person with exactly the name I'm looking for. Unfortunately, I also get all the similar names with this code.

import imdb

# creating instance of IMDb
ia = imdb.IMDb()

# list of names
names = ["Paul Alexander Abel", "Viktor Abel", "Heinz Abosch"]

# searching the name
for n in names:
    print("-----", n, "-----")
    search = ia.search_person(n)

# loop for printing the name and id
    for i in range(len(search)):
    # getting the id
        id = search[i].personID
        print(search[i]['name'] + " : " + id)
# output:
----- Viktor Abel -----
Viktor Vrabec : 0903968
Viktor Brabec : 0102632
Viktor Abroi : 6636627
Viktor Absolutov : 5153732
Viktoriia Bessarab : 10441797
Viktoriya Brabec : 13413004
Viktor Abolduyev : 0008850
Viktor Abramov : 12453191
Viktor Abramov : 11944753
Viktor Abakumov : 12360818
Viktor Abramovskiy : 3277781
Viktor Abramyan : 8311765
Viktor Abrosimov : 1480489
Viktoriya Belyakova : 11558430
Viktoriya Belova : 1495496
Viktoriya Belyaeva : 5274884
Viktoria Believein : 3637309
Viktoria Belovonskaya : 10260945
Viktoriya Belyavskaya : 10267906
Viktorie Isabella Ter-Akopow : 9422886
----- Heinz Abosch -----
Heinz Ambrosch : 0024376

Is there a way to change that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

行至春深 2025-01-22 20:48:59

限制返回结果的数量:

# The first result is the best match
search = ia.search_person(n, results=1)[0]

您的循环:

for n in names:
    print("-----", n, "-----")
    search = ia.search_person(n, results=1)[0]
    if search['name'].lower() == n.lower():
        id = search.personID
        print(search['name'] + " : " + id)

Limit the number of result returned:

# The first result is the best match
search = ia.search_person(n, results=1)[0]

Your loop:

for n in names:
    print("-----", n, "-----")
    search = ia.search_person(n, results=1)[0]
    if search['name'].lower() == n.lower():
        id = search.personID
        print(search['name'] + " : " + id)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文