-1

I want scrape this string "O email não é válido." from this script tag

$(function() {
                ,messages: {
                        "resetPasswordEmail": {
                                required: "O email é de preenchimento obrigatório."
                                ,remote: "O email não é válido."
                        }
        });
});

I try many of solution but its not work

script = soup.find_all('script')
#print(script)
for item in script:
    if 'remote' in item.string:
        print('Validoooo')
    else:
        print('nooooooooo') 
Jamiu S.
  • 5,257
  • 5
  • 12
  • 34

1 Answers1

0

Welcome to stackoverflow! since what you are checking for is just a "does this string exist in this other string", you could simply check if your input contains the substring "O email não é válido" you can find out more on how to do this in this post: Does Python have a string 'contains' substring method?

if you still want to use regex, i would use semething like this:

isMatch = soup.match("remote: *\"O email não é válido\.\"")
if isMatch:
        print('Validoooo')
    else:
        print('nooooooooo') 

i dont know where you get the input string, but it looks like some kind of server response? if there is more data like eg. status codes, you should use those instead of language specific checks for strings in response.

please let me know if i got something wrong about your question! if i was able to help you, i would appreciate it if you could mark is answer as helpful.

A-New-User
  • 61
  • 3