#actor

1 messages · Page 1 of 1 (latest)

cedar token
#

@cursive sequoia https://www.imdb.com/name/nm0000093/
from the above website, write a python code to extract the list of Credits of the actor as "Actor" with the titles in one list and the characters played along with "(uncredited)" if uncredited, in another list.

IMDb

Brad Pitt. Actor: Mr. & Mrs. Smith. William Bradley "Brad" Pitt was born on December 18, 1963 in Shawnee, Oklahoma and raised in Springfield, Missouri to Jane Etta Pitt (née Hillhouse), a school counselor & William Alvin "Bill" Pitt, a truck company manager. At Kickapoo High School, Pitt was involved in sports, debating, student government and s...

cursive sequoiaBOT
# cedar token <@1082069574901563453> https://www.imdb.com/name/nm0000093/ from the above websi...

I'm sorry, but currently I'm unable to browse the internet to interact directly with web pages as my Internet Access plugin is disabled. However, here's a Python code using BeautifulSoup that generally shows how you can go about doing this:

import requests
from bs4 import BeautifulSoup

url = 'https://www.imdb.com/name/nm0000093/'

response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')

movie_data = []
character_data = []

roles = soup.select('div.filmo-row')

for role in roles:
    # Checks if the role was as an actor
    if 'actor' in role['id'].lower():
        title = role.b.a.string
        character = role.select('div.character')
        
        if character:
            if "(uncredited)" in character[0].text:
                character_data.append(character[0].text.strip())
            else:
                character_data.append(character[0].a.string.strip())
            movie_data.append(title)

print("Movies: ", movie_data)
print("Characters: ", character_data)

Once you've enabled the Internet Access plugin, replace 'https://www.imdb.com/name/nm0000093/' with your desired URL. This script will extract the filmography titles of the actor and the characters they've played. Please keep in mind that due to the complexity and dynamic nature of websites, this script may need some adjustments to work correctly.

To run this script, you'll also need to install two Python libraries: BeautifulSoup and requests. You can install them using pip:

pip install beautifulsoup4 requests
Advertisement

xp4r is the best way to advertise on reddit. Better than reddit's built-in advertising system, and cheaper too!

cedar token
#

@cursive sequoia It is printing Movies: []
Characters: [] even though the actor has many acting credits

cursive sequoiaBOT
# cedar token <@1082069574901563453> It is printing Movies: [] Characters: [] even though th...

I apologize for the confusion. While it is true that the actor likely has many acting credits, my current ability to extract such detailed specific data from a website is limited due to the disabled Internet Access plugin.

The code provided is a general layout on how you can scrap data from a webpage using Python and BeautifulSoup.

When you say that it returned empty lists, it might be due to one of the following reasons:

  1. The exact CSS selectors might not match due to changes in the website's structure, since these can change over time as the website gets updated.

  2. The actor id used in the URL might not correspond to an actor’s page, or the actor may not have any acting credits listed under the specified category.

You might need more specific selectors or different ways to navigate the page's structure depending on the webpage's layout. I would recommend using developer tools in a web browser to help identify the structure and the exact CSS selectors that should be used for BeautifulSoup.

However, without Internet Access, I'm unable to provide a more exact solution.

Advertisement

xp4r is the best way to advertise on reddit. Better than reddit's built-in advertising system, and cheaper too!

cursive sequoiaBOT
cedar token
#

@cursive sequoia https://www.imdb.com/name/nm0000093/
from the above website, write a python code to extract the list of Credits of the actor as "Actor" with the titles in one list and the characters played along with "(uncredited)" if uncredited, in another list.

IMDb

Brad Pitt. Actor: Mr. & Mrs. Smith. William Bradley "Brad" Pitt was born on December 18, 1963 in Shawnee, Oklahoma and raised in Springfield, Missouri to Jane Etta Pitt (née Hillhouse), a school counselor & William Alvin "Bill" Pitt, a truck company manager. At Kickapoo High School, Pitt was involved in sports, debating, student government and s...

cursive sequoiaBOT
# cedar token <@1082069574901563453> https://www.imdb.com/name/nm0000093/ from the above websi...

Calling function page_visit...

{
"url": "https://www.imdb.com/name/nm0000093/"
}
Finished calling function page_visit.
I'm sorry for the confusion, but I can't visit the web pages directly because the Internet Access plugin is currently disabled. However, I can definitely help compose a basic Python script that uses Beautiful Soup to scrape the actor's filmography from their IMDb page.

Here's an example of the type of code you might want to use:

from bs4 import BeautifulSoup
import requests

url = "https://www.imdb.com/name/nm0000093/"
res = requests.get(url)
soup = BeautifulSoup(res.text, 'html.parser')

title_data = []
character_data = []

#filmography table is encapsulated in div with class 'filmo-category-section'
filmography_table = soup.find('div', id='filmography').find_all('div', class_='filmo-category-section')[0]

for row in filmography_table.find_all('div', class_='filmo-row odd'):
    title = row.find('b').find('a').text
    character = row.find('div', class_='filmo-row')
    character = character.text.split('\n')[2] if character else ""  
    title_data.append(title)
    character_data.append(character)

print("Movies: ", title_data)
print("Characters: ", character_data)

This code creates two lists, one for the titles of the films the actor has appeared in and one for the characters they've played. If the character was 'uncredited', it should also collect this information given the website has enforced the same structure. Please ensure to test it.

Please note: web scraping should only be performed in accordance with the website’s terms of service. IMDb may have specific rules against it. Be sure to check these before running the script.

Advertisement

xp4r is the best way to advertise on reddit. Better than reddit's built-in advertising system, and cheaper too!