Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nas validações em que existem valores que deveriam ser URL #678

Open
robertatakenaka opened this issue Aug 6, 2024 · 1 comment
Open
Assignees

Comments

@robertatakenaka
Copy link
Member

Descrição da tarefa

Nas validações em que existem valores que deveriam ser URL, adicione se o conteúdo é uma URL.
Note exemplos como:
https://articlemeta.scielo.org/api/v1/article/?collection=cub&code=S1024-94352003000500002&format=xmlwos

Observe que, apesar de não ser o XML SciELO, todos os supostos links, não estão corretos, isso pode causar problemas nos conteúdos a serem exportados. Use estes exemplos como fora do padrão de URL.

# código gerado por IA, verificar se funciona
import urllib.parse

def is_url_like(text):
  """Checks if a given text string resembles a URL pattern using urllib.parse."""
  try:
    parsed_url = urllib.parse.urlparse(text)
    return bool(parsed_url.scheme) and bool(parsed_url.netloc)
  except ValueError:
    return False

# Examples
text1 = "https://www.example.com"
text2 = "This is not a URL"

print(is_url_like(text1))  # Output: True
print(is_url_like(text2))  # Output: False
@robertatakenaka
Copy link
Member Author

@gitnnolabs @samuelveigarangel PSI

This was referenced Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants