Posts by Sinf0r0s0 • 111 points
10 posts
-
1
votes1
answer289
viewsA: How to remove an excerpt from a specific text in a PDF with Python
Use the module re import re texto = """inscrições estaduais baixadas 123456 pag 32.1 lore inscrições estaduais baixadas 123123 gj inscrições estaduais baixadas 111111 quam efficitur dignissim. Nam…
-
0
votes1
answer57
viewsA: Pydantic - Convert "str" to "bool"
Use the Developer validator: from pydantic import BaseModel, ValidationError, validator class Usuario(BaseModel): id: int nome: str ativo: str @validator('ativo') def converte_valores(cls, v): if v…
-
0
votes1
answer54
viewsA: How to use beatifulsoup to search for a certain word on the page
To recover the javascript object data inside the script TAG: import requests from bs4 import BeautifulSoup import json html_text =…
-
0
votes1
answer112
viewsA: Run Python files using python
yes, this is inherent in programming languages. The "right" way is to import the x.py file as a module. see: x py. print('olá do modulo X') def main(): print('olá da função principal "x.main()"') if…
-
1
votes2
answers346
viewsA: Is it possible to run a python script that is in another directory?
To run the script . py you need to call the interpreter python import subprocess if __name__ == '__main__': cmd = r"python /caminho/para/a/pasta/main.py -username abcd -password 1234"…
-
1
votes5
answers115
viewsA: Browse lists of different sizes
Use itertools cycle. Assuming you know that x is the shortest list and using list comprehension in one row only: from itertools import cycle x = [1, 2, 3] y = [4, 5, 6, 7, 8, 9] m = [a + b for a, b…
-
0
votes2
answers205
viewsA: Copy line and write the same line to another file using python
Use rstrip() to remove all spaces, new lines and pipes. Whenever you want to "see" if there is any type of white space in a string try to transfer it into a list: palavra = 'teste \n\t\r'…
-
0
votes3
answers740
views -
0
votes2
answers100
viewsA: How do I restart the page if Selenium does not find the element on the page?
from selenium import webdriver from selenium.common import exceptions as ex import time url = 'https://google.com' driver =…
-
2
votes1
answer232
viewsA: How to automate PDF download with Selenium?
[EDIT] Yes I used the url you indicated and modified "slightly" import os import lxml.html as parser import requests class DiarioOficial(): _header = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0;…