Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #39447

Re: Urllib's urlopen and urlretrieve

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python3': 0.05; 'urllib2': 0.07; 'python': 0.09; 'information?': 0.09; 'links.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'whole.': 0.09; 'archive': 0.11; 'library': 0.15; '2.7.3': 0.16; 'formatting,': 0.16; 'gmane': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'urllib': 0.16; 'wrote:': 0.17; 'library,': 0.17; 'thu,': 0.17; 'feb': 0.19; 'trying': 0.21; 'bit': 0.21; 'import': 0.21; 'doc': 0.22; 'programming': 0.23; '(you': 0.23; 'header:User-Agent:1': 0.26; 'language.': 0.27; 'header:X-Complaints-To:1': 0.28; 'this?': 0.28; 'really,': 0.29; 'probably': 0.29; 'books': 0.30; 'url:python': 0.32; 'could': 0.32; 'print': 0.32; 'certain': 0.33; 'extract': 0.33; 'hopefully': 0.33; 'requirement.': 0.33; 'problem': 0.33; 'anyone': 0.33; 'to:addr:python-list': 0.33; 'know.': 0.33; 'languages': 0.33; 'another': 0.33; 'list': 0.35; 'something': 0.35; 'there': 0.35; 'received:org': 0.36; 'but': 0.36; 'url:org': 0.36; 'charset:us-ascii': 0.36; 'does': 0.37; 'why': 0.37; 'communicate': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'things': 0.38; 'nothing': 0.38; 'page': 0.38; 'advice': 0.39; 'to:addr:python.org': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'skip:u 10': 0.60; 'kind': 0.61; 'free': 0.61; 'email addr:gmail.com': 0.63; 'making': 0.64; 'internet': 0.71; 'lack': 0.71; 'topic,': 0.78; '2013': 0.84; 'lastly,': 0.84; 'received:sd.cox.net': 0.84; 'online,': 0.98
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From rh <richard_hubbe11@lavabit.com>
Subject Re: Urllib's urlopen and urlretrieve
Date Thu, 21 Feb 2013 09:55:17 -0800
References <34998ea2-6b19-4a98-8ea0-389aca0192ca@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host ip68-227-87-145.sb.sd.cox.net
User-Agent dsodnetnin
X-Mailer EZnn0.37p
X-Newsreader EZnn0.37p
X-Gmane-NNTP-Posting-Host EZnn0.37p
Original-Received from slem by 1.1 with local
X-No-Archive yes
Archive no
X-Archive expiry=11
X-Archive encrypt
X-Operating-System Barebones_6.1
X-Gmane-NNTP-Posting-Host 192.168.1.1
X-NNTP-Posting-Host 192.168.1.1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2187.1361469299.2939.python-list@python.org> (permalink)
Lines 40
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1361469299 news.xs4all.nl 6944 [2001:888:2000:d::a6]:34562
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:39447

Show key headers only | View raw


On Thu, 21 Feb 2013 04:12:52 -0800 (PST)
qoresucks@gmail.com wrote:

> I only just started Python and given that I know nothing about
> network programming or internet programming of any kind really, I
> thought it would be interesting to try write something that could
> create an archive of a website for myself. With this I started trying
> to use the urllib library, however I am having a problem
> understanding why certain things wont work with the
> urllib.urlretrieve and urllib.urlopen then reading.
> 
> Why is it that when using urllib.urlopen then reading or
> urllib.urlretrieve, does it only give me parts of the sites, loosing
> the formatting, images, etc...? How can I get around this?

urllib2 is the standard library in 2.7.3 to use, in 3.3 it is urllib
straight from the doc page

import urllib2
f = urllib2.urlopen('http://www.python.org/')
print f.read(100)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?xml-stylesheet href="./css/ht2html

And so your journey begins.  With recursing into links, etc., etc.
> 
> Lastly, while its a bit off topic, I lack a good understanding of
> network programming as a whole. From making programs communicate or
> to simply extract data from URL's, I don't know where to even begin,
> which has lead me to learning python to better understand it
> hopefully then carry it over to other languages I know. Can anyone
> give me some advice on where to begin learning this information? Even
> if its in another language.

Also since you're new you may want to work with python3 but not
a requirement.

There are lots of free books online, search this list for links.
(you can search this list at gmane and probably elsewhere)

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Urllib's urlopen and urlretrieve qoresucks@gmail.com - 2013-02-21 04:12 -0800
  Re: Urllib's urlopen and urlretrieve Michael Herman <hermanmu@gmail.com> - 2013-02-21 04:59 -0800
    Re: Urllib's urlopen and urlretrieve qoresucks@gmail.com - 2013-02-21 21:09 -0800
      Re: Urllib's urlopen and urlretrieve Dave Angel <davea@davea.name> - 2013-02-22 12:05 -0500
      Re: Urllib's urlopen and urlretrieve MRAB <python@mrabarnett.plus.com> - 2013-02-22 17:18 +0000
    Re: Urllib's urlopen and urlretrieve qoresucks@gmail.com - 2013-02-21 21:09 -0800
  Re: Urllib's urlopen and urlretrieve Dave Angel <davea@davea.name> - 2013-02-21 10:56 -0500
  Re: Urllib's urlopen and urlretrieve rh <richard_hubbe11@lavabit.com> - 2013-02-21 09:47 -0800
  Re: Urllib's urlopen and urlretrieve rh <richard_hubbe11@lavabit.com> - 2013-02-21 09:55 -0800
  Re: Urllib's urlopen and urlretrieve Dave Angel <davea@davea.name> - 2013-02-21 13:04 -0500
  Re: Urllib's urlopen and urlretrieve Dave Angel <davea@davea.name> - 2013-02-21 13:53 -0500

csiph-web