Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76313 > unrolled thread
| Started by | Simon Evans <musicalhacksaw@yahoo.co.uk> |
|---|---|
| First post | 2014-08-14 08:09 -0700 |
| Last post | 2014-08-14 10:04 -0600 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.python
Code to Python 27 prompt to access a html file stored on C drive Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-08-14 08:09 -0700
Re: Code to Python 27 prompt to access a html file stored on C drive alister <alister.nospam.ware@ntlworld.com> - 2014-08-14 15:33 +0000
Re: Code to Python 27 prompt to access a html file stored on C drive Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-14 10:04 -0600
| From | Simon Evans <musicalhacksaw@yahoo.co.uk> |
|---|---|
| Date | 2014-08-14 08:09 -0700 |
| Subject | Code to Python 27 prompt to access a html file stored on C drive |
| Message-ID | <4d7cb33a-ccb9-4961-94de-80d807084179@googlegroups.com> |
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.
[toc] | [next] | [standalone]
| From | alister <alister.nospam.ware@ntlworld.com> |
|---|---|
| Date | 2014-08-14 15:33 +0000 |
| Message-ID | <VE4Hv.151616$Cd5.120@fx03.am4> |
| In reply to | #76313 |
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()
--
Due to the CDA, we no longer have a root account.
[toc] | [prev] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2014-08-14 10:04 -0600 |
| Message-ID | <mailman.13002.1408032322.18130.python-list@python.org> |
| In reply to | #76316 |
On Thu, Aug 14, 2014 at 9:33 AM, alister
<alister.nospam.ware@ntlworld.com> 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.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web