Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'tutorial': 0.03; 'output': 0.05; 'subject:Python': 0.06; 'modifying': 0.07; 'subject:file': 0.07; 'url:software': 0.09; 'python': 0.11; "computer's": 0.16; 'programmers,': 0.16; 'subject:access': 0.16; 'subject:drive': 0.16; 'url.': 0.16; 'wrote:': 0.18; 'server,': 0.19; "skip:' 30": 0.19; 'slightly': 0.19; 'thu,': 0.19; 'examples': 0.20; 'help.': 0.21; 'code,': 0.22; 'example': 0.22; 'import': 0.22; 'aug': 0.22; 'print': 0.22; 'subject:Code': 0.24; 'pass': 0.26; 'header:In- Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; "skip:' 10": 0.31; '-0700,': 0.31; 'skip:= 20': 0.31; 'file': 0.32; 'proceed': 0.33; 'received:google.com': 0.35; '14,': 0.36; 'addresses,': 0.36; 'similar': 0.36; 'to:addr :python-list': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'read': 0.60; 'hope': 0.61; 'such': 0.63; 'dear': 0.65; 'direct': 0.67; 'prompt': 0.68; 'online': 0.71; 'inline': 0.74; '(inclusive': 0.84; 'drive.': 0.84; 'yours': 0.88 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=ANj5w/rfqJvJSjx5qNwauzj1FtcgCS8eDph8kg/UFAk=; b=KhJ+zs1wRpK0OC1xWYiPLcIkyBq3iM8hDFNa5I1771KHLOhm4AwInoMRRUS9m6SL7L fD4biYLZ1nTm+27ObgqBOoCfqDG8W8jNZ/ms/PgSnN47c3Vi1j4W0fdNn3hAM9jWTdiP rBToi/DoUmTTCwxP90sF/iyqoGnzJ4xcSP7eZVU0LGKoIRTcJOsdPbEDwMJY14XB16jg Yc82mGg6ftWy1cqY6NThVwJl/KfDgMMT3+u7hfhPpoQhfjPfhX8DflDAcOBjRNuRw//h DnMb7ygtBXr6DbXdSE7qZFT9JZ2E0zl0CWa/PUF7ZxowNOLC2Jcqi53i/u1ENeg1+HIr gv+w== X-Received: by 10.66.119.39 with SMTP id kr7mr5142859pab.131.1408032312821; Thu, 14 Aug 2014 09:05:12 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <4d7cb33a-ccb9-4961-94de-80d807084179@googlegroups.com> From: Ian Kelly Date: Thu, 14 Aug 2014 10:04:32 -0600 Subject: Re: Code to Python 27 prompt to access a html file stored on C drive To: Python Content-Type: text/plain; charset=UTF-8 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: , Newsgroups: comp.lang.python Message-ID: Lines: 44 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1408032322 news.xs4all.nl 2866 [2001:888:2000:d::a6]:44235 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:76318 On Thu, Aug 14, 2014 at 9:33 AM, alister wrote: > On Thu, 14 Aug 2014 08:09:11 -0700, Simon Evans wrote: > >> Dear Programmers, I want to access a html file on my C drive, in the >> >> Python 27 prompt, all the examples I come across seem to require for >> >> access for the html file be on a server, rather than on the same >> >> computer's C drive. I want to do this as a prerequisite to writing >> >> webscraping code, surmising that if I can get the Python 27 >> >> prompt (inclusive of 'Beautiful Soup''Urllib' 'Requests' downloads ) to >> >> output pertinent html code from a html document, then I can proceed to >> use >> >> similar code to ouput html code from URL addresses, such as >> >> 'RacingPost.com' 'SportingLife.com''Oddschecker.com' and >> >> 'Bestbetting.com' which is what I am interested in working on. >> >> Hope you can help. >> >> Yours Simon Evans. > > have you read the online tutorial > > http://crummy.com/software/BeautifulSoup/bs3/documentation.html > > > modifying the example slightly to read from a file rather than inline > code would give (typed direct so untested) > > from BeautifulSoup import BeautifulSoup as bs > > data =open('myfile').read() > soup=bs(data) > print soup.prettify() Alternatively you can continue to use urlopen and just pass it a file:// URL.