Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #39521
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!border1.nntp.ams2.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <qoresucks@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'essentially': 0.04; '21,': 0.07; 'granted,': 0.07; 'python': 0.09; 'agree,': 0.09; 'expected.': 0.09; 'fetch': 0.09; 'information?': 0.09; 'to:addr:comp.lang.python': 0.09; 'whole.': 0.09; 'wrong,': 0.09; 'cc:addr:python-list': 0.10; 'archive': 0.11; 'library': 0.15; 'background,': 0.16; 'comparison.': 0.16; 'etc...': 0.16; 'formatting,': 0.16; 'grasp': 0.16; 'herman': 0.16; 'specific,': 0.16; 'urllib': 0.16; 'versed': 0.16; 'webpage,': 0.16; 'later': 0.16; 'wrote:': 0.17; 'library,': 0.17; 'thu,': 0.17; 'requests': 0.18; 'windows': 0.19; 'feb': 0.19; 'trying': 0.21; 'bit': 0.21; 'import': 0.21; 'os,': 0.22; 'help.': 0.22; 'programming': 0.23; 'cc:2**1': 0.24; 'linux': 0.24; 'tried': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'looks': 0.26; 'am,': 0.27; 'cc:addr:gmail.com': 0.27; 'language.': 0.27; 'primarily': 0.27; 'this?': 0.28; 'initial': 0.28; 'noticed': 0.28; 'attempted': 0.29; 'lessons': 0.29; 'really,': 0.29; 'though.': 0.29; 'url:mailman': 0.29; 'probably': 0.29; "i'm": 0.29; 'initially': 0.30; 'thursday,': 0.30; 'figure': 0.30; 'code': 0.31; 'url:python': 0.32; 'mac': 0.32; 'quickly': 0.32; 'could': 0.32; 'url:listinfo': 0.32; 'getting': 0.33; 'certain': 0.33; 'extract': 0.33; 'hopefully': 0.33; 'html,': 0.33; 'largely': 0.33; 'programming,': 0.33; 'problem': 0.33; 'anyone': 0.33; 'code:': 0.33; 'know.': 0.33; 'languages': 0.33; 'another': 0.33; 'version': 0.34; 'received:google.com': 0.34; 'programming.': 0.35; 'so,': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'there': 0.35; 'really': 0.36; 'michael': 0.36; 'skip:u 20': 0.36; 'but': 0.36; 'url:org': 0.36; 'cc:no real name:2**1': 0.36; "wasn't": 0.36; "didn't": 0.36; 'method': 0.36; 'anything': 0.36; 'should': 0.36; 'thank': 0.36; 'too': 0.36; 'enough': 0.36; 'does': 0.37; 'why': 0.37; 'communicate': 0.37; 'rather': 0.37; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'easier': 0.38; 'skip:o 20': 0.38; 'some': 0.38; 'things': 0.38; 'nothing': 0.38; 'sure': 0.38; 'page': 0.38; 'advice': 0.39; 'instead': 0.39; 'little': 0.39; 'where': 0.40; 'url:mail': 0.40; 'your': 0.60; 'lost': 0.60; 'from:no real name:2**0': 0.60; 'skip:u 10': 0.60; 'further': 0.61; 'first': 0.61; 'kind': 0.61; 'more': 0.63; 'fun': 0.64; 'making': 0.64; 'webpage': 0.65; 'due': 0.66; 'internet': 0.71; 'lack': 0.71; 'topic,': 0.78; '2013': 0.84; 'lastly,': 0.84; 'url:st': 0.84; 'adopting': 0.91; 'responses': 0.93 |
| X-Received | by 10.49.1.43 with SMTP id 11mr27348qej.29.1361509791057; Thu, 21 Feb 2013 21:09:51 -0800 (PST) |
| Newsgroups | comp.lang.python |
| Date | Thu, 21 Feb 2013 21:09:50 -0800 (PST) |
| In-Reply-To | <mailman.2162.1361451589.2939.python-list@python.org> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=99.121.53.60; posting-account=XH8cbwoAAADsKhxZKJ-sG4EEz1Bcfsty |
| References | <34998ea2-6b19-4a98-8ea0-389aca0192ca@googlegroups.com> <mailman.2162.1361451589.2939.python-list@python.org> |
| User-Agent | G2/1.0 |
| X-Google-Web-Client | true |
| X-Google-IP | 99.121.53.60 |
| MIME-Version | 1.0 |
| Subject | Re: Urllib's urlopen and urlretrieve |
| From | qoresucks@gmail.com |
| To | comp.lang.python@googlegroups.com |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| Cc | python-list@python.org, qoresucks@gmail.com |
| 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> |
| Message-ID | <mailman.2238.1361509800.2939.python-list@python.org> (permalink) |
| Lines | 119 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1361509800 news.xs4all.nl 6873 [2001:888:2000:d::a6]:55527 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:39521 |
Show key headers only | View raw
Initially I was just trying the html, but later when I attempted more complicated sites that weren't my own I noticed that large bulks of the site were lost in the process. The urllib code essentially looks like what I was trying but it didn't work as I had expected.
To be more specific, after I got it working for my own little page, I attempted to take it further and get all the lessons from Learn Python The Hard Way. When I tried the same method on the first intro page to see if I was even getting it right, the html code was all there but upon opening it I noticed the format was all wrong, colors were off for the background, images, etc... were all missing. So clearly I ended up misunderstanding something and its something critical I need to understand.
As for the OS, I primarily use Mac OS, however well versed in linux and windows if there is anything specific out there that might help.
As for which version if Python, I have been using Python 2 to learn on as I heard that Python 3 was still largely unadopted due to a lack of library support etc... by comparison. Are people adopting it fast enough now that I should consider learning on 3 instead of 2?
Also, it isn't so much to do it for technical reasons but rather I thought it would be something interesting and fun to learn some form of internet/network programming. Granted, its not the best approach, but I'm not really aware of too many others, and I it does seem interesting to me.
Python programming probably isn't the best way to initially approach this I agree, but I wasn't sure what to research on or to get a better grasp of network/internet/web programming so I figured I would just dive head first and figure things out, and reinforce more programming while learning internet/network programming was my initial goal.
Thank you all for your responses though. :)
On Thursday, February 21, 2013 7:59:26 AM UTC-5, Michael Herman wrote:
> Are you just trying to get the html? If so, you can use this code-
>
>
>
> import urllib
>
>
> # fetch the and download a webpage, nameing it test.html
> urllib.urlretrieve("http://www.web2py.com/", filename="test.html")
>
>
>
>
>
>
> I recommend using the requests library, as it's easier to use and more powerful:
>
>
>
>
>
>
>
>
>
> import requests
>
> # retrive the webpage
> r = requests.get("http://www.web2py.com/")
>
> # write the content to test_request.html
> with open("test_requests.html", "wb") as code:
>
>
>
>
>
> code.write(r.content)
>
> If you want to get up to speed quickly on internet programming, I have a course I am developing. It's on kickstarter - http://kck.st/VQj8hq. The first section of the book dives into web fundamentals and internet programming.
>
>
>
>
>
>
>
> On Thu, Feb 21, 2013 at 4:12 AM, <qore...@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?
>
>
>
> 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.
>
>
>
> --
>
> http://mail.python.org/mailman/listinfo/python-list
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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