Enviado em 30/01/2016 - 02:07h
Olá pessoal do VOL, escrevi um código python no qual queria que ele consultasse o preço de um fone de ouvido e imprimisse na tela, porém me deparei com esse erro que nunca tinha visto antes, se alguém puder me explicar o que aconteceu e me mostrar a solução agradeço desde já!!! Aí está o código e em seguida o erro:Enviado em 30/01/2016 - 04:52h
Para a indentação correta você precisa colocar o código entre abre code e fecha code: [ code ] e [ /code ] sem esses espaços dentro dos colchetes. Tem um botão no formulário do tópico com o ícone </>. Se você selecionar o tópico com o mouse e clicar no botão com esse ícone seu código fica indentado certinhoEnviado em 30/01/2016 - 18:11h
import urllib.request import json url = 'http://www.americanas.com.br/produto/122339264/fone-de-ouvido-com-microfone-aquarius-headphone-preto-bluetooth' fonte = urllib.request.urlopen(url).read() html = str(json.loads(fonte.decode('utf-8'))) tag = ('R$') x = html.find(tag) while '{' in html[x:x + 4]: html = html[x + 4:] x = html.find(tag) #fim do while z = html.find(',') print (html[:z+3])
Enviado em 30/01/2016 - 22:22h
import urllib.request import json url = 'http://www.americanas.com.br/produto/122339264/fone-de-ouvido-com-microfone-aquarius-headphone-preto-bluetooth' fonte = urllib.request.urlopen(url).read() html = str(json.loads(fonte.decode('utf-8'))) tag = ('R$') x = html.find(tag) while '{' in html[x:x + 4]: html = html[x + 4:] x = html.find(tag) #fim do while z = html.find(',') print (html[:z+3])
import urllib.request <-- esta errado o certo é import urllib
fonte = urllib.urlopen(url).read()
Enviado em 31/01/2016 - 00:47h
import urllib.request import json url = 'http://www.americanas.com.br/produto/122339264/fone-de-ouvido-com-microfone-aquarius-headphone-preto-bluetooth' fonte = urllib.request.urlopen(url).read() html = str(json.loads(fonte.decode('utf-8'))) tag = ('R$') x = html.find(tag) while '{' in html[x:x + 4]: html = html[x + 4:] x = html.find(tag) #fim do while z = html.find(',') print (html[:z+3])
import urllib.request <-- esta errado o certo é import urllib
fonte = urllib.urlopen(url).read()
Enviado em 06/07/2016 - 12:09h
Tem 2 problemas a parte de json me parece desnecessária e o site das americanas parece estar verificando se a reuisição vem de um navegador comercial.#!/usr/bin/env python3 import urllib.request import json url = 'http://python.org/' html = str(urllib.request.urlopen(url).read()) #html = str(json.loads(fonte.decode('utf-8'))) tag = ('R$') x = html.find(tag) while '{' in html[x:x + 4]: html = html[x + 4:] x = html.find(tag) #fim do while z = html.find(',') print (html[:z+3])
Resolver problemas de Internet
Como compartilhar a tela do Ubuntu com uma Smart TV (LG, Samsung, etc.)
Descritores de Arquivos e Swappiness
Como instalar no Linux Jogos da Steam só para Windows
Instalando o Team Viewer no Debian Trixie - problema no Policykit
O Que Fazer Após Instalar Ubuntu 25.04
Problema ao iniciar o Opensuse Tumbleweed (3)
Erro ao atualizar o archlinux [RESOLVIDO] (3)