extraindo preço do site

101 views
Skip to first unread message

Roberson Bruno

unread,
Jan 2, 2013, 7:02:43 AM1/2/13
to python...@googlegroups.com
Galera, estou estudando programação e usando a linguagem python.

Estou tentando extrair o preço do site: http:www.beans-r-us.biz/prices.html

estou usando esse código:

import urllib.request

page = urllib.request.urlopen ("http:www.beans-r-us.biz/prices.html")
text = page.read().decode("utf8")

print(text)

porém quando rodo está dando isso:

Traceback (most recent call last):
File "/Users/macbook_17/Desktop/Python/preco_cafe.py", line 3, in <module>
page = urllib.request.urlopen ("http:www.beans-r-us.biz/prices.html")
File "/Library/Frameworks/Python.framework/Versions/3.0/lib/python3.0/urllib/request.py", line 122, in urlopen
return _opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.0/lib/python3.0/urllib/request.py", line 356, in open
req = meth(req)
File "/Library/Frameworks/Python.framework/Versions/3.0/lib/python3.0/urllib/request.py", line 1011, in do_request_
raise URLError('no host given')
urllib.error.URLError: <urlopen error no host given>

onde não consta o valor do grão.


dede já agradeço o help…

Abrass!

Geraldo Andrade

unread,
Jan 2, 2013, 7:04:54 AM1/2/13
to python...@googlegroups.com
Faltou o http:// em page = urllib.request.urlopen ("http:www.beans-r-us.biz/prices.html")

2013/1/2 Roberson Bruno <robers...@gmail.com>

page = urllib.request.urlopen ("http:www.beans-r-us.biz/prices.html")



--
Geraldo Andrade

Web Developer

Mobile: 82 9621-4159
Skype Phone: geraldoandrade.a
Twitter: http://twitter.com/geraldoandradee
GTalk: ger...@geraldoandrade.com
Msn: ger...@geraldoandrade.com

Luiz Gustavo Costa

unread,
Jan 2, 2013, 7:07:43 AM1/2/13
to python...@googlegroups.com
* Roberson Bruno (robers...@gmail.com) wrote:
> Galera, estou estudando programação e usando a linguagem python.
>
> Estou tentando extrair o preço do site: http:www.beans-r-us.biz/prices.html

acho que estão faltando as "//" na url, ou tire o http:, deixe somente
"www.beans-r-us.biz/prices.html"

>
>
> page = urllib.request.urlopen ("http:www.beans-r-us.biz/prices.html")
>
> dede já agradeço o help…
>
> Abrass!
---
Luiz Gustavo Costa (Powered by BSD)
*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+
mundoUnix - Consultoria em Software Livre
http://www.mundounix.com.br
ICQ: 2890831 / MSN: con...@mundounix.com.br
Tel: 55 (21) 4063-7110 / 8194-1905 / (11) 4063-0407
Blog: http://www.luizgustavo.pro.br

Roberson Bruno

unread,
Jan 2, 2013, 7:08:05 AM1/2/13
to python...@googlegroups.com
era isso mesmo!!!

Valeu demais galera!
> --
> --
> ------------------------------------
> Grupo Python-Brasil
> http://www.python.org.br/wiki/AntesDePerguntar
>
> <*> Para visitar o site do grupo na web, acesse:
> http://groups.google.com/group/python-brasil
>
> <*> Para sair deste grupo, envie um e-mail para:
> python-brasi...@googlegroups.com
>
>
>

Reply all
Reply to author
Forward
0 new messages