473,320 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Parsing data from URL

I am trying to do the following:

<of course website.com is not the actual site>

import urllib

url = 'http://www.website.com/file.shtml'
dat = urllib.urlopen(url, 'r').read()
print dat

When I do so, I get the following data:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>405 Method Not Allowed</TITLE>
</HEAD><BODY>
<H1>Method Not Allowed</H1>
The requested method POST is not allowed for the URL <P>
<HR>
<ADDRESS>Apache/1.3.27 Server at website.com Port 80</ADDRESS>
</BODY></HTML>

How can I make sure that I get the actual html data instead of the data
from redirected URL?

thanks,

Harlin

Jul 19 '05 #1
3 2031
I think it depends on the server

On 24 Apr 2005 17:24:18 -0700, Harlin Seritt <ha**********@yahoo.com> wrote:
I am trying to do the following:

<of course website.com is not the actual site>

import urllib

url = 'http://www.website.com/file.shtml'
dat = urllib.urlopen(url, 'r').read()
print dat

When I do so, I get the following data:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>405 Method Not Allowed</TITLE>
</HEAD><BODY>
<H1>Method Not Allowed</H1>
The requested method POST is not allowed for the URL <P>
<HR>
<ADDRESS>Apache/1.3.27 Server at website.com Port 80</ADDRESS>
</BODY></HTML>

How can I make sure that I get the actual html data instead of the data
from redirected URL?

thanks,

Harlin

--
http://mail.python.org/mailman/listinfo/python-list

Jul 19 '05 #2
On Monday 25 April 2005 01:24, Harlin Seritt wrote:
dat = urllib.urlopen(url, 'r').read()


Drop the 'r' - urlopen is posting the 'r' to the server, instead of doing what
you mean, opening the file read-only.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQBCbFAxY6W16wIJgxQRAglyAJ0QLdG8MDmUUpZjhQIbxV 2QIr0CgwCcDu17
/I7VIjGXvvmAphR+FODCJqo=
=JwOd
-----END PGP SIGNATURE-----

Jul 19 '05 #3
"The Great 'Harlin Seritt' uttered these words" on 4/24/2005 8:24 PM:
How can I make sure that I get the actual html data instead of the data
from redirected URL?

thanks,

Harlin


Harlin,

I am not sure I understand what you are asking but please see if the
below mentioned link will help you. I am just sending the URL that I
believe is relevant to you. You may want to read the entire chapter if
you are interested.

http://diveintopython.org/http_web_s...redirects.html

(Dive into Python's Chapter 11.7. Handling redirects)

Thanks,
-Kartic
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Kylotan | last post by:
I have a text file where the fields are delimited in various different ways. For example, strings are terminated with a tilde, numbers are terminated with whitespace, and some identifiers are...
8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
3
by: Girish | last post by:
Hi All, I have written a component(ATL COM) that wraps Xerces C++ parser. I am firing necessary events for each of the notifications that I have handled for the Content and Error handler. The...
4
by: ralphNOSPAM | last post by:
Is there a function or otherwise some way to pull out the target text within an XML tag? For example, in the XML tag below, I want to pull out 'CALIFORNIA'. ...
3
by: Pir8 | last post by:
I have a complex xml file, which contains stories within a magazine. The structure of the xml file is as follows: <?xml version="1.0" encoding="ISO-8859-1" ?> <magazine> <story>...
1
by: yonido | last post by:
hello, my goal is to get patterns out of email files - say "message forwarding" patterns (message forwarded from: xx to: yy subject: zz) now lets say there are tons of these patterns (by gmail,...
9
by: ankitdesai | last post by:
I would like to parse a couple of tables within an individual player's SHTML page. For example, I would like to get the "Actual Pitching Statistics" and the "Translated Pitching Statistics"...
5
by: randy | last post by:
Can some point me to a good example of parsing XML using C# 2.0? Thanks
3
by: toton | last post by:
Hi, I have some ascii files, which are having some formatted text. I want to read some section only from the total file. For that what I am doing is indexing the sections (denoted by .START in...
13
by: Chris Carlen | last post by:
Hi: Having completed enough serial driver code for a TMS320F2812 microcontroller to talk to a terminal, I am now trying different approaches to command interpretation. I have a very simple...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.