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: 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: 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> 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: 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 Initially I was just trying the html, but later when I attempted more compl= icated sites that weren't my own I noticed that large bulks of the site wer= e lost in the process. The urllib code essentially looks like what I was tr= ying but it didn't work as I had expected. To be more specific, after I got it working for my own little page, I attem= pted 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 e= ven getting it right, the html code was all there but upon opening it I not= iced the format was all wrong, colors were off for the background, images, = etc... were all missing. So clearly I ended up misunderstanding something a= nd its something critical I need to understand.=20 As for the OS, I primarily use Mac OS, however well versed in linux and win= dows if there is anything specific out there that might help.=20 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 s= upport 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/ne= twork programming. Granted, its not the best approach, but I'm not really a= ware of too many others, and I it does seem interesting to me.=20 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 n= etwork/internet/web programming so I figured I would just dive head first a= nd figure things out, and reinforce more programming while learning interne= t/network programming was my initial goal.=20 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- >=20 >=20 >=20 > import urllib >=20 >=20 > # fetch the and download a webpage, nameing it test.html > urllib.urlretrieve("http://www.web2py.com/", filename=3D"test.html") >=20 >=20 >=20 >=20 >=20 >=20 > I recommend using the requests library, as it's easier to use and more po= werful: >=20 >=20 >=20 >=20 >=20 >=20 >=20 >=20 >=20 > import requests >=20 > # retrive the webpage > r =3D requests.get("http://www.web2py.com/") >=20 > # write the content to test_request.html > with open("test_requests.html", "wb") as code: =A0=20 >=20 >=20 >=20 >=20 >=20 > code.write(r.content) >=20 > If you want to get up to speed quickly on internet programming, I have a = course I am developing. It's on kickstarter -=A0http://kck.st/VQj8hq. The f= irst section of the book dives into web fundamentals and internet programmi= ng.=A0 >=20 >=20 >=20 >=20 >=20 >=20 >=20 > On Thu, Feb 21, 2013 at 4:12 AM, wrote: >=20 >=20 > I only just started Python and given that I know nothing about network pr= ogramming or internet programming of any kind really, I thought it would be= interesting to try write something that could create an archive of a websi= te for myself. With this I started trying to use the urllib library, howeve= r I am having a problem understanding why certain things wont work with the= urllib.urlretrieve and urllib.urlopen then reading. >=20 >=20 >=20 >=20 >=20 > Why is it that when using urllib.urlopen then reading or urllib.urlretrie= ve, does it only give me parts of the sites, loosing the formatting, images= , etc...? How can I get around this? >=20 >=20 >=20 > 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 extr= act 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 ot= her languages I know. Can anyone give me some advice on where to begin lear= ning this information? Even if its in another language. >=20 >=20 >=20 > -- >=20 > http://mail.python.org/mailman/listinfo/python-list