#๐Ÿ”’ Removing NA values from my code

17 messages ยท Page 1 of 1 (latest)

worldly spearBOT
#

@unkempt pulsar

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

#

Hey @unkempt pulsar!

It looks like you're trying to paste code into this channel.

Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes it easier for us to help you.

To do this, use the following method:
```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
You can **edit your original message** to correct your code block.
unkempt pulsar
#
def get_tomatometer_percentage(movie_name):
    #url = f"https://www.rottentomatoes.com/m/{movie_name.lower().replace(' ', '_')}"
    #url = f"https://www.rottentomatoes.com/m/{movie_name.lower().replace(' ', '_').replace(':', '_').replace(',', '_')}"
    formatted_movie_name = movie_name.lower().replace(' ', '_').replace('-', '').replace(':', '').replace(',', '')
    url = f"https://www.rottentomatoes.com/m/{formatted_movie_name}"
    response = requests.get(url)
    
    if response.status_code == 200:
        soup = BeautifulSoup(response.content, "html.parser")
        tomatometer_elem = soup.find("rt-text", {"size": "1.375", "theme": "medium"})
        if tomatometer_elem:
            tomatometer = tomatometer_elem.text.strip()
            return tomatometer
    return "N/A"  # Return "N/A" when tomatometer couldn't be found or webpage couldn't be accessed```
random magnet
#

Data=[a for a in data if a!="N/A"]

unkempt pulsar
#

i know this will be a dumb question but its saying ' Data" is not defined

random magnet
#

Well that was an example on how to remove them from a list if u can be a little more specific i can maybe better understand and help what u need

unkempt pulsar
#

is there anyway i can send you a link of the whole code ?
only because besides the NA issue, Everytime i run the code , it times out on page 14, i also am experiancing issues where its not really scrapping the whole site, its just scapping a portion of the information , it might be because the links are incomplete but idk

random magnet
#

Ok so i have to go to sleep
Scraping may be rule 5 and the answer to the how to send code is !paste

#

!rule 5

worldly spearBOT
#

5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.

random magnet
#

!paste

worldly spearBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

unkempt pulsar
#

rule 5 states if its deemed inappropriate, malicious, or illegal right ?
I think i should be good in that case no ?

#

and thanks for the paste, ill have to paste it on there and see if someone else can help me out since you have to go to sleep

worldly spearBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.

#

๐Ÿ”’ Removing NA values from my code