Skip to content

Commit

Permalink
Merge pull request #7 from gabrielfava/branch_fava
Browse files Browse the repository at this point in the history
Branch fava
  • Loading branch information
gabrielfava authored Feb 25, 2018
2 parents 37a6ed6 + b7e379e commit 0f11d14
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
49 changes: 49 additions & 0 deletions Modulos/ProvasPassadas/aux_scraping.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#ASAPY
import requests
__URL_GLOBAL = "https://www.urionlinejudge.com.br";

def printme(pagina):
body = getCorpo(__URL_GLOBAL+"/judge/pt/problems/view/"+pagina);
iInicio = find_str(body, "<iframe");
pos = (body[iInicio:]);
iFim = find_str(pos, ">")+1;
tupla = pos[:iFim];
page2 = getAttr(tupla,"src");

bodyframe = getCorpo(__URL_GLOBAL+page2);
print(bodyframe);

return;


def find_str(s, char):
index = 0
if char in s:
c = char[0]
for ch in s:
if ch == c:
if s[index:index+len(char)] == char:
return index
index += 1
return -1

#TODO - TRATAR EQUIVALENCIA DE SINTAXE !
def getAttr(tupla, atributo):
tamanhoAtr = len(atributo)+2; #ja apaga atributo="
inicioAtr = find_str(tupla, atributo)+tamanhoAtr;
if inicioAtr == -1:
return "ERRO"
fimAttr = find_str(tupla[inicioAtr:], '"');
return tupla[inicioAtr:inicioAtr+fimAttr];

def getCorpo(req):
page = requests.get(req);
return str(page.content);


printme("2166")


#print("titulo => URI Online Judge - Problema 2166 - Raiz Quadrada de 2")
#print("autor => M.C. Pinto, UNILA")
#print("probm => ma das formas de calcular a raiz quadrada de um n\xc3\xbamero natural")
7 changes: 7 additions & 0 deletions Modulos/ProvasPassadas/provas_passadas.core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import requests
printme(2661)
# retorna corpo da pagina
def printme(id):
page = requests.get("https://www.urionlinejudge.com.br/judge/pt/problems/view/"+id);
print(page.content);
return;

0 comments on commit 0f11d14

Please sign in to comment.